Bug 58603 - In using Xamarin Forms with F# Getting “PushAsync is not supported globally on iOS…” but while USING NavigationPage
Summary: In using Xamarin Forms with F# Getting “PushAsync is not supported globally o...
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.5
Hardware: Macintosh Mac OS
: --- critical
Target Milestone: ---
Assignee: Bugzilla
URL: https://stackoverflow.com/questions/4...
Depends on:
Blocks:
 
Reported: 2017-08-05 21:40 UTC by Terrance Smith
Modified: 2017-08-09 17:49 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Terrance Smith 2017-08-05 21:40:02 UTC
# Steps to reproduce
namespace Eclipsefest

open System
open Xamarin.Forms
open Xamarin.Forms.Xaml

type MenuItem = 
{ Title : string
  TargetType : System.Type }

type MenuPage() = 
inherit ContentPage()
let _ = base.LoadFromXaml(typeof<MenuPage>)
member this.Handle_Tapped(sender : Object, arg : EventArgs) = 
    let navItem = sender :?> TextCell
    async { 
        match navItem.Text with
        | "Information" -> 
            do! this.Navigation.PushAsync(page = new NavigationPage(new InfoPage()))
                |> Async.AwaitIAsyncResult
                |> Async.Ignore
        | "Events" -> 
            do! this.Navigation.PushAsync(new NavigationPage(new EventsPage()))
                |> Async.AwaitIAsyncResult
                |> Async.Ignore
        | "BusRoute" -> 
            do! this.Navigation.PushAsync(new NavigationPage(new BusRoutePage()))
                |> Async.AwaitIAsyncResult
                |> Async.Ignore
        | "Glasses" -> 
            do! this.Navigation.PushAsync(new NavigationPage(new GlassesPage()))
                |> Async.AwaitIAsyncResult
                |> Async.Ignore
        | "Merch" -> 
            do! this.Navigation.PushAsync(new NavigationPage(new MerchPage()))
                |> Async.AwaitIAsyncResult
                |> Async.Ignore
        | "Day" -> 
            do! this.Navigation.PushAsync(new NavigationPage(new DayPage()))
                |> Async.AwaitIAsyncResult
                |> Async.Ignore
        | "About" -> 
            do! this.Navigation.PushAsync(new NavigationPage(new AboutPage()))
                |> Async.AwaitIAsyncResult
                |> Async.Ignore
        | _ -> 
            do! this.Navigation.PushAsync(new NavigationPage(new EclipsefestPage()))
                |> Async.AwaitIAsyncResult
                |> Async.Ignore
    }
    |> Async.RunSynchronously

Or

open System
open Xamarin.Forms
open Xamarin.Forms.Xaml

type MenuItem = 
    { Title : string
      TargetType : System.Type }

type MenuPage() = 
    inherit ContentPage()
    let _ = base.LoadFromXaml(typeof<MenuPage>)
    member this.Handle_Tapped(sender : Object, arg : EventArgs) = 
        this.Navigation.PushAsync(new NavigationPage(new EclipsefestPage())) |> ignore

# Expected behavior
Navigate to a new page

# Actual behavior
Throws
System.InvalidOperationException: PushAsync is not supported globally on iOS, please use a NavigationPage.
  at Xamarin.Forms.Platform.iOS.Platform.Xamarin.Forms.INavigation.PushAsync (Xamarin.Forms.Page root, System.Boolean animated) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Platform.cs:154
  at Xamarin.Forms.NavigationProxy.OnPushAsync (Xamarin.Forms.Page page, System.Boolean animated) [0x00022] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\NavigationProxy.cs:190
  at Xamarin.Forms.NavigationProxy.PushAsync (Xamarin.Forms.Page root, System.Boolean animated) [0x00013] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\NavigationProxy.cs:109
  at Xamarin.Forms.NavigationProxy.OnPushAsync (Xamarin.Forms.Page page, System.Boolean animated) [0x00022] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\NavigationProxy.cs:190
  at Xamarin.Forms.NavigationProxy.PushAsync (Xamarin.Forms.Page root, System.Boolean animated) [0x00013] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\NavigationProxy.cs:109
  at Xamarin.Forms.NavigationProxy.OnPushAsync (Xamarin.Forms.Page page, System.Boolean animated) [0x00022] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\NavigationProxy.cs:190
  at Xamarin.Forms.NavigationProxy.PushAsync (Xamarin.Forms.Page root, System.Boolean animated) [0x00013] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\NavigationProxy.cs:109
  at Xamarin.Forms.NavigationProxy.PushAsync (Xamarin.Forms.Page root) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\NavigationProxy.cs:102
  at <StartupCode$Eclipsefest>.$MenuPage.xaml+Handle_Tapped@17.Invoke (Microsoft.FSharp.Core.Unit unitVar) [0x00090] in /Users/terrancesmith/Projects/Eclipsefest/Eclipsefest/MenuPage.xaml.fs:19
  at Microsoft.FSharp.Control.AsyncBuilderImpl+callA@851[b,a].Invoke (Microsoft.FSharp.Control.AsyncParams`1[T] args) [0x00047] in <5584acdb904cf4daa7450383dbac8455>:0
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151
  at Microsoft.FSharp.Control.AsyncBuilderImpl.commit[a] (Microsoft.FSharp.Control.AsyncBuilderImpl+Result`1[T] res) [0x00030] in <5584acdb904cf4daa7450383dbac8455>:0
  at Microsoft.FSharp.Control.CancellationTokenOps.RunSynchronously[a] (System.Threading.CancellationToken token, Microsoft.FSharp.Control.FSharpAsync`1[T] computation, Microsoft.FSharp.Core.FSharpOption`1[T] timeout) [0x000a3] in <5584acdb904cf4daa7450383dbac8455>:0
  at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T] (Microsoft.FSharp.Control.FSharpAsync`1[T] computation, Microsoft.FSharp.Core.FSharpOption`1[T] timeout, Microsoft.FSharp.Core.FSharpOption`1[T] cancellationToken) [0x00071] in <5584acdb904cf4daa7450383dbac8455>:0
  at Eclipsefest.MenuPage.Handle_Tapped (System.Object sender, System.EventArgs arg) [0x00008] in /Users/terrancesmith/Projects/Eclipsefest/Eclipsefest/MenuPage.xaml.fs:16
  at Xamarin.Forms.Cell.OnTapped () [0x00008] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Cells\Cell.cs:106
  at Xamarin.Forms.TextCell.OnTapped () [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Cells\TextCell.cs:82
  at Xamarin.Forms.TableView+TableSectionModel.OnRowSelected (System.Object item) [0x00007] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\TableView.cs:214
  at Xamarin.Forms.TableModel.RowSelected (System.Object item) [0x0001a] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\TableModel.cs:65
  at Xamarin.Forms.TableModel.RowSelected (System.Int32 section, System.Int32 row) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\TableModel.cs:57
  at Xamarin.Forms.Platform.iOS.TableViewModelRenderer.RowSelected (UIKit.UITableView tableView, Foundation.NSIndexPath indexPath) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\TableViewModelRenderer.cs:85
  at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/UIKit/UIApplication.cs:79
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/UIKit/UIApplication.cs:63
  at Eclipsefest.iOS.Main.main (System.String[] args) [0x00001] in <59853c0a6da8a60ca74503830a3c8559>:0
i
# Supplemental info (logs, images, videos)
For more details
https://stackoverflow.com/questions/45524358/getting-pushasync-is-not-supported-globally-on-ios-while-using-navigationpa#comment78012873_45524358

# Test environment (full version information)
Running Visual Studio for Mac (Community)
Version 7.0.1(Build 24)


=== Visual Studio Community 2017 for Mac ===

Version 7.0.1 (build 24)
Installation UUID: a5d75eff-793e-4da3-ac2e-0f5238bfd560
Runtime:
	Mono 5.0.1.1 (2017-02/5077205) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 500010001

=== NuGet ===

Version: 4.0.0.2323

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
SDK: /usr/local/share/dotnet/sdk/1.0.4/Sdks
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.0.1/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.5.4
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 8.3.3 (12175.1)
Build 8E3004b

=== Xamarin.Mac ===

Version: 3.4.0.36 (Visual Studio Community)

=== Xamarin.iOS ===

Version: 10.10.0.36 (Visual Studio Community)
Hash: d2270eec
Branch: d15-2
Build date: 2017-05-22 16:30:53-0400

=== Xamarin.Android ===

Version: 7.3.1.2 (Visual Studio Community)
Android SDK: /Users/terrancesmith/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.0.3  (API level 15)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
		6.0    (API level 23)
		7.0    (API level 24)
		7.1    (API level 25)

SDK Tools Version: 25.2.5
SDK Platform Tools Version: 25.0.5
SDK Build Tools Version: 25.0.3

Java SDK: /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Inspector ===

Version: 1.2.2
Hash: b71b035
Branch: d15-1
Build date: Fri, 21 Apr 2017 17:57:12 GMT

=== Build Information ===

Release ID: 700010024
Git revision: 7ab1ca2ced6f584e56b7a0d4d321d00775cd95c9
Build date: 2017-05-19 05:44:51-04
Xamarin addins: 08d17158f3365beee5e60f67999e607cce4b3f93
Build lane: monodevelop-lion-d15-2

=== Operating System ===

Mac OS X 10.12.5
Darwin 16.6.0 Darwin Kernel Version 16.6.0
    Fri Apr 14 16:21:16 PDT 2017
    root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

Android Signature Tool 2.1.2
AddinMaker 1.3.7
NuGet Package Explorer 0.2
NuGet Package Management Extensions 0.12.2
Paket 0.3
xUnit.NET 2 testing framework support 0.7.5
Redth's Addins 1.0.9
Straight8's SpecFlow Integration 1.11.1.0
Manifest.addin 0.0.0.0


the project file
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
	<PropertyGroup>
		<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
		<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
		<ProjectGuid>{3E77752F-A5E6-4C82-BEC7-C32FCB0A8143}</ProjectGuid>
		<TargetProfile>netcore</TargetProfile>
		<OutputType>Library</OutputType>
		<RootNamespace>Eclipsefest</RootNamespace>
		<AssemblyName>Eclipsefest</AssemblyName>
		<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
		<TargetFrameworkIdentifier>.NETPortable</TargetFrameworkIdentifier>
		<TargetFrameworkProfile>Profile259</TargetFrameworkProfile>
		<TargetFSharpCoreVersion>3.259.3.1</TargetFSharpCoreVersion>
	</PropertyGroup>
	<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
		<DebugSymbols>true</DebugSymbols>
		<DebugType>full</DebugType>
		<Optimize>false</Optimize>
		<OutputPath>bin\Debug</OutputPath>
		<DefineConstants>DEBUG</DefineConstants>
		<ErrorReport>prompt</ErrorReport>
		<PlatformTarget>
		</PlatformTarget>
	</PropertyGroup>
	<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
		<Optimize>true</Optimize>
		<OutputPath>bin\Release</OutputPath>
		<DefineConstants>
		</DefineConstants>
		<ErrorReport>prompt</ErrorReport>
		<GenerateTailCalls>true</GenerateTailCalls>
		<PlatformTarget>
		</PlatformTarget>
	</PropertyGroup>
	<ItemGroup>
		<Reference Include="System" />
		<Reference Include="mscorlib" />
		<Reference Include="Xamarin.Forms.Core">
			<HintPath>..\packages\Xamarin.Forms.2.3.4.231\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Core.dll</HintPath>
		</Reference>
		<Reference Include="Xamarin.Forms.Platform">
			<HintPath>..\packages\Xamarin.Forms.2.3.4.231\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Platform.dll</HintPath>
		</Reference>
		<Reference Include="Xamarin.Forms.Xaml">
			<HintPath>..\packages\Xamarin.Forms.2.3.4.231\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Xaml.dll</HintPath>
		</Reference>
		<Reference Include="FSharp.Core">
			<HintPath>..\packages\FSharp.Core.4.0.0.1\lib\portable-net45+netcore45+wpa81+wp8\FSharp.Core.dll</HintPath>
		</Reference>
		<Reference Include="ModernHttpClient">
		  <HintPath>..\packages\modernhttpclient.2.4.2\lib\Portable-Net45+WinRT45+WP8+WPA81\ModernHttpClient.dll</HintPath>
		</Reference>
		<Reference Include="Newtonsoft.Json">
		  <HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
		</Reference>
		<Reference Include="Xamarin.Forms.Theme.Base">
		  <HintPath>..\packages\Xamarin.Forms.Theme.Base.1.0.0.43-pre1\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Theme.Base.dll</HintPath>
		</Reference>
		<Reference Include="Xamarin.Forms.Pages">
		  <HintPath>..\packages\Xamarin.Forms.Pages.2.3.0.38-pre2\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Pages.dll</HintPath>
		</Reference>
		<Reference Include="Xamarin.Forms.Theme.Dark">
		  <HintPath>..\packages\Xamarin.Forms.Theme.Dark.1.0.0.43-pre1\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Theme.Dark.dll</HintPath>
		</Reference>
	</ItemGroup>
	<ItemGroup>
		<EmbeddedResource Include="BusRoutePage.xaml">
			<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
		</EmbeddedResource>
		<Compile Include="BusRoutePage.xaml.fs">
			<DependentUpon>BusRoutePage.xaml</DependentUpon>
		</Compile>
		<EmbeddedResource Include="GlassesPage.xaml">
			<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
		</EmbeddedResource>
		<Compile Include="GlassesPage.xaml.fs">
			<DependentUpon>GlassesPage.xaml</DependentUpon>
		</Compile>
		<EmbeddedResource Include="MerchPage.xaml">
			<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
		</EmbeddedResource>
		<Compile Include="MerchPage.xaml.fs">
			<DependentUpon>MerchPage.xaml</DependentUpon>
		</Compile>
		<EmbeddedResource Include="DayPage.xaml">
			<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
		</EmbeddedResource>
		<Compile Include="DayPage.xaml.fs">
			<DependentUpon>DayPage.xaml</DependentUpon>
		</Compile>
		<EmbeddedResource Include="AboutPage.xaml">
			<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
		</EmbeddedResource>
		<Compile Include="AboutPage.xaml.fs">
			<DependentUpon>AboutPage.xaml</DependentUpon>
		</Compile>
		<EmbeddedResource Include="EventsPage.xaml" />
		<Compile Include="EventsPage.xaml.fs">
			<DependentUpon>EventsPage.xaml</DependentUpon>
		</Compile>
		<EmbeddedResource Include="InfoPage.xaml" />
		<Compile Include="InfoPage.xaml.fs">
			<DependentUpon>InfoPage.xaml</DependentUpon>
		</Compile>
		<EmbeddedResource Include="EclipsefestPage.xaml" />
		<Compile Include="EclipsefestPage.xaml.fs">
			<DependentUpon>EclipsefestPage.xaml</DependentUpon>
		</Compile>
		<EmbeddedResource Include="Root.xaml" />
		<Compile Include="Root.xaml.fs">
			<DependentUpon>Root.xaml</DependentUpon>
		</Compile>
		<EmbeddedResource Include="App.xaml" />
		<Compile Include="App.xaml.fs">
			<DependentUpon>App.xaml</DependentUpon>
		</Compile>
		<Compile Include="AssemblyInfo.fs" />
		<None Include="packages.config" />
	</ItemGroup>
	<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.Portable.FSharp.Targets" />
	<Import Project="..\packages\Xamarin.Forms.2.3.4.231\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets" Condition="Exists('..\packages\Xamarin.Forms.2.3.4.231\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets')" />
	<ProjectExtensions>
	  <MonoDevelop>
	    <Properties>
	      <Policies>
	        <TextStylePolicy FileWidth="120" TabWidth="4" IndentWidth="4" RemoveTrailingWhitespace="True" EolMarker="Native" TabsToSpaces="True" NoTabsAfterNonTabs="True" scope="text/x-fsharp">
	          <inheritsSet />
	          <inheritsScope />
	        </TextStylePolicy>
	        <FSharpFormattingPolicy scope="text/x-fsharp">
	          <DefaultFormat IndentOnTryWith="True" ReorderOpenDeclaration="True" SpaceAfterComma="True" SpaceAfterSemicolon="True" SpaceAroundDelimiter="True" SpaceBeforeArgument="True" SpaceBeforeColon="True" __added="0" />
	          <inheritsSet />
	          <inheritsScope />
	        </FSharpFormattingPolicy>
	      </Policies>
	    </Properties>
	  </MonoDevelop>
	</ProjectExtensions>
</Project>
Comment 1 Jimmy [MSFT] 2017-08-09 17:49:59 UTC
In the code you showed, you are wrapping the new page you want to push in a NavigationPage. However it's the page you are pushing _from_ that needs to be in a NavigationPage.

The easiest way to do this is to wrap your initial page in a NavigationPage then set it as the MainPage. Then you just push the new pages directly without wrapping them in another NavigationPage because doing so will cause other issues. Check it out: https://gist.github.com/jimmgarrido/d0b702c1282faa5bb91d0ed14e2d7e1b

Hope this helps!