Bug 37219 - Windows Phone PopAsync() on NavigationPage causes NullReferenceException
Summary: Windows Phone PopAsync() on NavigationPage causes NullReferenceException
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 2.0.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: E.Z. Hart [MSFT]
Depends on:
Reported: 2015-12-22 03:46 UTC by Adam
Modified: 2016-03-16 03:32 UTC (History)
2 users (show)

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

Logs (267.52 KB, application/x-zip-compressed)
2016-03-16 03:32 UTC, Adam

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:

Description Adam 2015-12-22 03:46:17 UTC
I created a custom renderer to display a MediaElement on a second page I pushed using PushAsync() using NavigationPage. This works wonderfully. The problem is when I try to use the back button to go back to my first page, the custom renderer for the media element complains at the "SetNativeControl(new MediaElement())" line.

protected override async void OnElementChanged(ElementChangedEventArgs<MyRenderer> e)

  if (Control == null)
    SetNativeControl(new MediaElement());

An exception of type 'System.NullReferenceException' occurred in Xamarin.Forms.Platform.WinRT.DLL but was not handled in user code
   at Xamarin.Forms.Platform.WinRT.VisualElementRenderer`2.SetNativeControl(TNativeElement control)
   at Blah.MyRenderer.<OnElementChanged>d__9.MoveNext()

Microsoft Visual Studio Professional 2015
Version 14.0.23107.0 D14REL
Microsoft .NET Framework
Version 4.6.00079

Installed Version: Professional

Visual Basic 2015   00322-50050-46449-AA877
Microsoft Visual Basic 2015

Visual C# 2015   00322-50050-46449-AA877
Microsoft Visual C# 2015

Windows Phone SDK 8.0 - ENU   00322-50050-46449-AA877
Windows Phone SDK 8.0 - ENU

Visual Studio Tools for Universal Windows Apps   14.0.23309.00 d14oob
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

Xamarin (1390b70)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android (d300845)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS (ea30b32)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 1 Adam 2015-12-22 14:25:34 UTC
This issue should be closed. Issue has already been reported:

Comment 2 E.Z. Hart [MSFT] 2016-02-27 00:03:37 UTC
(In reply to Adam from comment #1)
> This issue should be closed. Issue has already been reported:
> https://bugzilla.xamarin.com/show_bug.cgi?id=21457


I'm not sure that your issue is a duplicate; bug 21457 is an iOS issue and your issue seems to be on Windows. Can you attach a small project which reproduces the error you're seeing?
Comment 3 Jason Smith [MSFT] 2016-03-15 19:26:16 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we no longer believe it affects the current version of Xamarin.Forms. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.
For your convenience, we have created some reproduction best practices viewable here: https://gist.github.com/jassmith/92405c300e54a01dcc6d

Warm regards,
Xamarin Forms Team
Comment 4 Adam 2016-03-16 03:32:23 UTC
Created attachment 15421 [details]