Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
Created attachment 10694 [details]
The FormsApplicationDelegate class's FinishedLaunching method calls SetMainPage to set window's RootViewController and make the window key and visible. UpdatePage (called when the MainPage property of the application changes) also sets the window's root view controller, but it does an additional step of disposing the old root view controller.
As a result, ff you don't set the MainPage until after FinishedLaunching then UpdatePage crashes with a NullReferenceException when trying to dispose the old (null) root view controller.
SetMainPage should just call UpdateMainPage so that these two functions do the same thing, and then UpdateMainPage should check for null before trying to dispose the old view controller.
To reproduce run the attached project.
FYI, I know that it's expected to set the MainPage in the app's constructor, but I can't think of a technical reason that setting it in OnStart instead shouldn't work as expected.
I am also getting the same error using Xamarin Forms 188.8.131.5255. Thank you.
Should be fixed in 1.4.3 final
I have checked this issue with xamarin.forms.184.108.40.20664-pre3 and its working fine at my end.
Hence closing this issue.
Xamarin Studio 5.9.3 (build 1)
Installation UUID: 1a096c6f-0678-402e-89b2-a2c10f7e80e4
Mono 4.0.1 ((detached/ed1d3ec)
GTK+ 2.24.23 (Raleigh theme)
Package version: 400010044
Xcode 6.2 (6776)
Xamarin.iOS : 220.127.116.11 (Enterprise Edition)
Xamarin.Android : 18.104.22.168 (Enterprise Edition)
Xamarin.Mac : 22.214.171.124 (Enterprise Edition)
Mac OS X 10.9.4