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 17799 [details]
The project replicating the bug. There is Main Page and SecondPage. Switch Renderer is on SecondPage. If you click on hardware bach button, then you are not able to get bacj to MainPage.
1/ Run project on UWP
2/ Click the button with text "Second Page"
3/ Click hardware back button
It stucks on Second Page and the page is empty without switch.
In output window have those errors:
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.ni.dll
Exception thrown: 'System.NullReferenceException' in SwitchRendererUWP.UWP.exe
Exception thrown: 'System.NullReferenceException' in mscorlib.ni.dll
Exception thrown: 'System.AggregateException' in Xamarin.Forms.Core.dll
If you hit hardware back button again you can get to Main Page.
I tested out this bug with Xamarin.Forms stable 188.8.131.52 and prerelease 184.108.40.206-pre2.
Tested device: Nokia Lumia 550, +emulators
Let me know if you need additional info.
The error is in CustomSwitch_UWP, OnElementChanged. UWP itself is a bit more aggressive about cleaning up views that are no longer visible, so when the Back button is pressed, it disposes SecondPage and all of its controls, triggering the OnElementChanged event, setting the Control to null. It's good practice to do a null check on the Control (or on e.NewElement) before accessing its properties in OnElementChanged due to this scenario (you'll see that we do this in all of our renderers, too).
If this does not resolve your issue, please feel free to reopen this report with additional information.
Xamarin Forms Team