Skip to content

Handle missing Windows notification runtime module - #3301

Merged
TheCodeTraveler merged 2 commits into
mainfrom
jfversluis-investigate-windows-snackbar-failure
Sep 2, 2026
Merged

Handle missing Windows notification runtime module#3301
TheCodeTraveler merged 2 commits into
mainfrom
jfversluis-investigate-windows-snackbar-failure

Conversation

@jfversluis

Copy link
Copy Markdown
Member

Description of Change

.NET 11 MAUI uses Windows App SDK 2.3.1. In self-contained unpackaged Windows apps, AppNotificationManager.Register() can throw COMException (0x8007007E) because Microsoft.WindowsAppRuntime.Insights.Resource.dll is missing. This currently crashes app startup when SetShouldEnableSnackbarOnWindows(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 skips Unregister() 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

  • Has a linked Issue, and the Issue has been approved(bug) or Championed (feature/proposal)
  • Has tests
  • Has samples (no sample changes are required; the existing sample already enables Windows Snackbar registration)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard
  • Documentation created or updated (no public API or setup changes)

Additional information

Verified on Windows ARM64 with .NET 11 Preview 7 using an isolated self-contained unpackaged reproduction:

  • Register() reproduces the reported 0x8007007E exception and missing Insights resource message.
  • Show() succeeds after that registration failure.
  • Applying the filtered fallback allows the process to exit normally while retaining notification display.
  • The .NET 10 Windows Toolkit target builds successfully.
  • All 14 AppBuilderExtensionsTests pass.

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
Copilot AI lite review requested due to automatic review settings September 2, 2026 13:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Medium severity · 1 Low severity

New issues introduced by this change (2)
Severity Finding
Medium severity src/​CommunityToolkit.Maui/​Options.shared.csNotificationInvoked is subscribed before Register(). If Register() throws a non-filtered…
Low severity 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 calling Unregister() when registration never succeeded.
  • Log the known registration failure to Trace and 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.dll scenario, but the current predicate matches any 0x8007007E module-not-found COMException. That can unintentionally suppress unrelated missing-module failures from Register() 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.

Comment thread src/CommunityToolkit.Maui/Options.shared.cs
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f9b00297-d252-4601-9f52-13fbbb31b218

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Low severity src/​CommunityToolkit.Maui.UnitTests/​Extensions/​AppBuilderExtensionsTests.cs — If IsWindowsAppRuntimeModuleUnavailable is tightened to match the specific missing Insights… View resolved comment
Medium severity src/​CommunityToolkit.Maui/​Options.shared.csNotificationInvoked is subscribed before Register(). If Register() throws a non-filtered… View resolved comment

@TheCodeTraveler
TheCodeTraveler merged commit 6626704 into main Sep 2, 2026
10 checks passed
@TheCodeTraveler
TheCodeTraveler deleted the jfversluis-investigate-windows-snackbar-failure branch September 2, 2026 14:48
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants