Is there an existing issue for this?
Did you read the "Reporting a bug" section on Contributing file?
Current Behavior
A .NET MAUI app using multiple windows and enabling snackbar notifications for Windows via:
builder.UseMauiApp<App>().UseMauiCommunityToolkit(options => options.SetShouldEnableSnackbarOnWindows(true));
On the second window close (i.e., after opening, closing, reopening, and then closing the secondary window), the app crashes with an unhandled exception:
Element not found.
Not Registered for App Notifications!
and this stack trace:
at WinRT.ExceptionHelpers.g__Throw|38_0(Int32 hr)
at ABI.Microsoft.Windows.AppNotifications.IAppNotificationManagerMethods.Unregister(IObjectReference _obj)
at Microsoft.Windows.AppNotifications.AppNotificationManager.Unregister()
at CommunityToolkit.Maui.Options.<>c.b__22_4(Window _, WindowEventArgs ) in //src/CommunityToolkit.Maui/Options.cs:line 93
at Microsoft.Maui.MauiWinUIWindow.<>c__DisplayClass10_0.b__0(OnClosed del)
at Microsoft.Maui.LifecycleEvents.LifecycleEventServiceExtensions.InvokeLifecycleEvents[TDelegate](IServiceProvider services, Action`1 action)
at Microsoft.Maui.MauiWinUIWindow.OnClosed(Object sender, WindowEventArgs args)
at Microsoft.Maui.MauiWinUIWindow.OnClosedPrivate(Object sender, WindowEventArgs args)
at WinRT.EventSource_global__Windows_Foundation_TypedEventHandler_object__global__Microsoft_UI_Xaml_WindowEventArgs.EventState.b__1_0(Object sender, WindowEventArgs args)
at WinRT.GenericTypeInstantiations.Windows_Foundation_TypedEventHandler_2_object__Microsoft_UI_Xaml_WindowEventArgs.Do_Abi_Invoke(IntPtr thisPtr, IntPtr sender, IntPtr args)
Expected Behavior
The second window should open and close repeatedly without throwing an exception.
Steps To Reproduce
- Create a MAUI app and enable Windows Snackbar in MauiProgram.cs (or use the sample project linked to this ticket).
- Launch the app.
- Open the secondary window (via the “Click me” button in the sample).
- Close that window.
- Reopen the secondary window.
- Close it again - and observe the crash on the second close.
Link to public reproduction project repository
https://github.com/slovan/MultiWindowIssueRepro
Environment
- .NET MAUI CommunityToolkit: 12.0.0
- OS: Windows 11 Build 10.0.26100
- .NET MAUI: 9.0.301
Anything else?
Is there an existing issue for this?
Did you read the "Reporting a bug" section on Contributing file?
Current Behavior
A .NET MAUI app using multiple windows and enabling snackbar notifications for Windows via:
builder.UseMauiApp<App>().UseMauiCommunityToolkit(options => options.SetShouldEnableSnackbarOnWindows(true));On the second window close (i.e., after opening, closing, reopening, and then closing the secondary window), the app crashes with an unhandled exception:
and this stack trace:
Expected Behavior
The second window should open and close repeatedly without throwing an exception.
Steps To Reproduce
Link to public reproduction project repository
https://github.com/slovan/MultiWindowIssueRepro
Environment
Anything else?