[uwp] Frame.Navigate( typeof(non_xaml_class_derived_from_Page)) crashes w/ Native Toolchain

BuildCalc 6 Reputation points
2021-11-06T15:50:08.31+00:00

Describe the bug

When given a Non-XAML (pure code) class derived from Page, Frame.Navigate crashes when compiled using Native Toolchain.

Steps to reproduce the bug

USING SAMPLE PROJECT

  1. Clone the following repo: https://github.com/baskren/NativeToolchain_NonXamlPage_crash.git
  2. Run in Debug WITHOUT Native Toolchain
  3. Click NOT A XAML PAGE button to navigate from XAML PAGE to NOT A XAML PAGE, successfully
  4. Run in Debug WITH Native Toolchain or run in Release
  5. Click NOT A XAML PAGE button to crash app. ### FROM SCRATCH
  6. Create a new UWP App
  7. Create a new class file, named NoXaml.cs and derive the class NoXaml from Windows.UI.Xaml.Controls.Page
  8. Add [Windows.UI.Xaml.Data.Bindable] attribute to the NoXaml class
  9. In App.xaml.cs, replace rootFrame.Navigate(typeof(MainPage), e.Arguments); with rootFrame.Navigate(typeof(NoXaml), e.Arguments);
  10. In the project's options, enable the Native Toolchain
  11. Build, run, watch crash ## Expected behavior

Frame.Navigate works with Non-XAML Pages.

Screenshots

image

IDE

Visual Studio 2019

NuGet package version

No response

Project type

  • [X] Packaged
  • [X] Unpackaged ## Windows version

May 2021 Update (19043)

Additional context

Note: recommendation from https://github.com/microsoft/microsoft-ui-xaml/issues/1949 was applied

Universal Windows Platform (UWP)
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Nico Zhu (Shanghai Wicresoft Co,.Ltd.) 12,851 Reputation points
    2021-11-08T02:34:38.243+00:00

    Hello,
    Welcome to Microsoft Q&A!

    Frame.Navigate( typeof(non_xaml_class_derived_from_Page)) crashes w/ Native Toolchain

    Describe the bug

    First of all we can reproduce your problem. and I found you have post issue report in WinUI github. It was added needs-triage tag. So please pay attention to the following up where in the WinUI github. And I will keep follow up this problem. If I have any updates , I will also update below.

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments