Restore Windows notification registration compatibility - #3303
Conversation
Subscribe to notification callbacks before registering as required by Windows App SDK, and clean up the handler when registration fails. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The fix targets runtime/SDK-specific COM behavior on Windows and the PR is still marked draft pending tester verification.
Review tier: Lite
Findings: None
What changed in this PR
Restores Windows App SDK–compatible ordering for Snackbar notification registration by ensuring NotificationInvoked is subscribed before calling AppNotificationManager.Register(), preventing the .NET 10 / Windows App SDK 1.8 COMException (0x80070490) regression introduced by PR #3301.
Changes:
- Subscribe to
NotificationInvokedbeforeRegister()to satisfy Windows App SDK requirements. - Track registration success locally and reliably unsubscribe the handler in a
finallyblock when registration fails (including the known .NET 110x8007007Emodule-missing case).
| File | Description |
|---|---|
| src/CommunityToolkit.Maui/Options.shared.cs | Reorders Windows Snackbar notification event subscription to occur before registration and adds cleanup on registration failure. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Our vendor team has now tested this fix with both .NET 10 and .NET 11, and Windows Snackbar notification registration works correctly with both versions. |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The change is small, targeted, and aligns the Windows notification registration flow with Windows App SDK ordering requirements while preserving existing failure-handling behavior.
Review tier: Lite
Findings: None
Description of Change
PR #3301 made Snackbar notification initialization work on .NET 11, but its review-driven event subscription ordering broke .NET 10 with Windows App SDK 1.8. Subscribing to
NotificationInvokedafterRegister()throwsCOMException0x80070490because Windows App SDK requires event handlers to be subscribed before registration.This restores the required subscribe-before-
Register()ordering. A local registration-success flag is set only afterRegister()succeeds, and afinallyblock removes the handler whenever registration fails, including the already-handled .NET 110x8007007EInsights resource DLL failure and unexpected exceptions. Successful registrations retain the handler and existing shutdown cleanup.The ordering behavior was verified in isolation on both .NET 10 and .NET 11. The focused
AppBuilderExtensionsTestssuite passes, and the .NET 10 Windows library target builds successfully.This PR remains draft while our testers verify the fix before it is marked ready for review.
Linked Issues
PR Checklist
approved(bug) orChampioned(feature/proposal) — follow-up regression fix for Handle missing Windows notification runtime module #3301mainat time of PRAdditional information
The regression reproduces on .NET 10 / Windows App SDK 1.8 as
Element not found. Must register event handlers before calling Register(). On .NET 11, the known missing Insights resource DLL registration failure remains handled, while the pre-registration event subscription is now reliably removed.