PrismLibrary / Prism.Maui

This is an experimental repo. The code here will eventually be merged into the main Prism repo as a full fledged platform at which time this repo will be archived.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NullReferenceException WinUI.App.OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs) in Windows Maui Preview 10

Vroomer opened this issue · comments

Prism.Maui preview 9 worked well with Maui preview 9. After updating to Maui preview 10 WinUI.App.OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs) in App.xaml.cs (Windows platform) throws null reference exception. Was there a breaking change?

System.NullReferenceException

  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=WinRT.Runtime
  StackTrace:
   at WinRT.IInspectable..ctor(IObjectReference obj)
   at Microsoft.UI.Xaml.Window.<.ctor>b__21_0()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.get_Value()
   at Microsoft.UI.Xaml.Window.get__default()
   at Microsoft.UI.Xaml.Window.get_DispatcherQueue()
   at Microsoft.Maui.Controls.Compatibility.Forms.SetupInit(IMauiContext mauiContext, Window mainWindow, IEnumerable`1 rendererAssemblies, Nullable`1 maybeOptions)
   at Microsoft.Maui.Controls.Compatibility.Forms.Init(IActivationState state, Nullable`1 options)
   at Microsoft.Maui.Controls.Hosting.AppHostBuilderExtensions.<>c.<OnConfigureLifeCycle>b__1_0(Application app, LaunchActivatedEventArgs args)
   at Microsoft.Maui.MauiWinUIApplication.<>c__DisplayClass1_0.<OnLaunched>b__0(OnLaunching del)
   at Microsoft.Maui.LifecycleEvents.LifecycleEventServiceExtensions.InvokeLifecycleEvents[TDelegate](IServiceProvider services, Action`1 action)
   at Microsoft.Maui.MauiWinUIApplication.OnLaunched(LaunchActivatedEventArgs args)
   at MauiApp2.WinUI.App.OnLaunched(LaunchActivatedEventArgs args) in C:\Users\vikto\source\repos\MauiApp2\MauiApp2\Platforms\Windows\App.xaml.cs:line 29

  This exception was originally thrown at this call stack:
    [External Code]
    MauiApp2.WinUI.App.OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs) in App.xaml.cs

This is still present in Maui Preview 11 (running VS 2022 17.1 Preview 5). but with a different StackTrace:

Exception thrown: 'System.NullReferenceException' in Microsoft.WinUI.dll

at Microsoft.UI.Xaml.Window.get_ThisPtr()
at Microsoft.UI.Xaml.Window.op_Equality(Window x, Window y)
at Microsoft.UI.Xaml.Window.op_Inequality(Window x, Window y)
at Microsoft.Maui.Controls.Compatibility.Forms.SetupInit(IMauiContext mauiContext, Window mainWindow, IEnumerable1 rendererAssemblies, Nullable1 maybeOptions)
at Microsoft.Maui.Controls.Compatibility.Forms.Init(IActivationState state, Nullable1 options) at Microsoft.Maui.Controls.Hosting.AppHostBuilderExtensions.<>c.<OnConfigureLifeCycle>b__1_0(Application app, LaunchActivatedEventArgs args) at Microsoft.Maui.MauiWinUIApplication.<>c__DisplayClass1_0.<OnLaunched>b__2(OnLaunching del) at Microsoft.Maui.LifecycleEvents.LifecycleEventServiceExtensions.InvokeLifecycleEvents[TDelegate](IServiceProvider services, Action1 action)
at Microsoft.Maui.MauiWinUIApplication.OnLaunched(LaunchActivatedEventArgs args)
at PrismMauiDemo.WinUI.App.OnLaunched(LaunchActivatedEventArgs args) in C:\Users\ur\Source\Repos\Prism.Maui.Preview9\sample\PrismMauiDemo\Platforms\Windows\App.xaml.cs:line 26

Thanks for the report however the existing preview is built against a much older preview build of MAUI and many changes have been made to the Prism API since then. We will be looking more seriously at bug reports once the new preview is out if they still exist.