microsoft-ui-xaml: [uwp] Frame.Navigate( typeof(class_derived_from_Page)) crashes like a boss in Release
Describe the bug
frame.Navigate(typeof(survey_page)); crashes when survey_page is a simple class derived from Page, like this:
class survey_page : Page { ... }
But to make it more with a twist (i.e., let the programmers spend a few good hours cursing, and maybe they’ll figure it out), this works perfectly in Debug mode.
To make things even cooler, the crash is one of those “You’re f–ed” crash - even if you have a handler to catch ALL exceptions, it doesn’t get called.
This situation is also never described in the docs, so I really don’t know who’s fault it is:
- the “awesome” WinRT - my best is on this one
- poor documentation
- bug in UWP
Steps to reproduce the bug
- create a class
class survey_page : Page { ... }
- Create the rest of the code, and rejoice since it all works in debug mode.
- Do unpaid overtime figuring it out.
As a side note, if I create the class from the wizard, with a xaml behind it, it all works.
Screenshots


| Windows 10 version | Saw the problem? |
|---|---|
| November 2019 Update (18363) |
| Device form factor | Saw the problem? |
|---|---|
| Desktop |
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 20 (8 by maintainers)
Commits related to this issue
- Fixing crashing issue when navigating to Tags/Search views. https://github.com/microsoft/microsoft-ui-xaml/issues/1949#issuecomment-596837959 — committed to latestchatty/werd by boarder2 6 years ago
Yes, the reflection provider appears to be why this works in Debug but not Release. The reflection provider won’t work in Release builds since they use .NET Native, which has restricted reflection support.
To get the scenario working in Release, you can add the Windows.UI.Xaml.Data.Bindable attribute to the survey_page class so there will be generated type information for it in the IXamlMetadataProvider, and the Xaml framework can correctly use/navigate to it: