Handle missing Windows notification runtime module - #3301
Conversation
Allow Windows snackbar notifications to continue when Windows App SDK registration fails because the Insights resource DLL is missing, while disabling action callbacks and avoiding an invalid unregister call. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f9b00297-d252-4601-9f52-13fbbb31b218
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The current registration path can leave the event handler subscribed on unexpected Register() failures, and the module-not-found filter is broader than described unless tightened (with tests updated accordingly).
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Lite
Findings: 1
New issues introduced by this change (2)
| Severity | Finding |
|---|---|
src/CommunityToolkit.Maui/Options.shared.cs — NotificationInvoked is subscribed before Register(). If Register() throws a non-filtered… |
|
src/CommunityToolkit.Maui.UnitTests/Extensions/AppBuilderExtensionsTests.cs — If IsWindowsAppRuntimeModuleUnavailable is tightened to match the specific missing Insights… |
What changed in this PR
This PR hardens Windows Snackbar startup behavior by handling a specific Windows App SDK registration failure (AppNotificationManager.Register() throwing COMException 0x8007007E) so apps don’t crash during launch in self-contained unpackaged scenarios, while still allowing Snackbar display (with action callbacks disabled when registration can’t be established).
Changes:
- Wrap Windows
AppNotificationManager.Register()in a filtered exception handler and avoid callingUnregister()when registration never succeeded. - Log the known registration failure to
Traceand remove the notification-invoked handler to disable action callbacks in the fallback path. - Add a unit test for the helper that detects the module-not-found COMException scenario.
| File | Description |
|---|---|
src/CommunityToolkit.Maui/Options.shared.cs |
Adds guarded Windows notification manager registration/unregistration and a helper predicate for the known module-not-found failure. |
src/CommunityToolkit.Maui.UnitTests/Extensions/AppBuilderExtensionsTests.cs |
Adds test coverage for the new COMException predicate used in the Windows fallback path. |
Suppressed comments (1)
src/CommunityToolkit.Maui/Options.shared.cs:158
- The PR description says this fallback should handle only the known missing
Microsoft.WindowsAppRuntime.Insights.Resource.dllscenario, but the current predicate matches any0x8007007Emodule-not-found COMException. That can unintentionally suppress unrelated missing-module failures fromRegister()and make debugging harder. Consider also checking the message for the expected module name before swallowing the exception.
internal static bool IsWindowsAppRuntimeModuleUnavailable(System.Runtime.InteropServices.COMException exception)
=> exception.HResult is moduleNotFoundHResult;
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f9b00297-d252-4601-9f52-13fbbb31b218
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The fallback is narrowly scoped, preserves unrelated failures, and includes focused regression coverage.
Review tier: Balanced
Findings: None
Issues resolved since last review (2)
| Severity | Finding |
|---|---|
src/CommunityToolkit.Maui.UnitTests/Extensions/AppBuilderExtensionsTests.cs — If IsWindowsAppRuntimeModuleUnavailable is tightened to match the specific missing Insights… View resolved comment |
|
src/CommunityToolkit.Maui/Options.shared.cs — NotificationInvoked is subscribed before Register(). If Register() throws a non-filtered… View resolved comment |


Description of Change
.NET 11 MAUI uses Windows App SDK 2.3.1. In self-contained unpackaged Windows apps,
AppNotificationManager.Register()can throwCOMException(0x8007007E) becauseMicrosoft.WindowsAppRuntime.Insights.Resource.dllis missing. This currently crashes app startup whenSetShouldEnableSnackbarOnWindows(true)is enabled.This change handles only that known module-not-found failure. Snackbar notifications can still be displayed, but action callbacks are disabled for the affected runtime configuration. The failure is written to
Trace, the event handler is removed, and shutdown skipsUnregister()when registration did not succeed. Other registration failures continue to propagate.The behavior is tracked upstream by microsoft/WindowsAppSDK#6071 and remains reproducible with Windows App SDK 2.3.1.
Linked Issues
PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information
Verified on Windows ARM64 with .NET 11 Preview 7 using an isolated self-contained unpackaged reproduction:
Register()reproduces the reported0x8007007Eexception and missing Insights resource message.Show()succeeds after that registration failure.AppBuilderExtensionsTestspass.