Bug 31736 - Dispose(Boolean) of Xamarin.Forms.Platform.WinRT.VisualElementRenderer causes exception
Summary: Dispose(Boolean) of Xamarin.Forms.Platform.WinRT.VisualElementRenderer causes...
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 1.4.4
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Eric Maupin
Depends on:
Reported: 2015-07-08 04:09 UTC by Frank Neumann
Modified: 2015-07-14 19:35 UTC (History)
3 users (show)

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:

Description Frank Neumann 2015-07-08 04:09:04 UTC

we encountered the following bug when using Xamarin.Forms for Windows Store apps:

When hitting the back button a page using NControl-based elements will be destroyed. More precisely the Dispose(Boolean) method of the Xamarin.Forms.Platform.WinRT.VisualElementRenderer will be called. Within this method, SetElement() is called.
Unfortunately this causes a call of the event handler OnElementChanged(), which tries to reinitilize the element based on the condition Control != null. Here we see, that the current sequence does not make sense.

In my opinion the Dispose(Boolean) method of the Xamarin.Forms.Platform.WinRT.VisualElementRenderer should call Element = null instead of SetElement(null) as on Android.

Best regards,

Comment 1 Jason Smith [MSFT] 2015-07-14 19:35:01 UTC
The reason SetElement is called is that you can use that single method to unhook events from the Element that you would otherwise need to duplicate into Dispose. We wanted to bring this everywhere but cant really do it as it would be a massive breaking change. We will at some point in the future take this break with a major release.