Skip to content

Restore Windows notification registration compatibility - #3303

Merged
TheCodeTraveler merged 1 commit into
mainfrom
jfversluis-fix-windows-notification-registration
Sep 3, 2026
Merged

Restore Windows notification registration compatibility#3303
TheCodeTraveler merged 1 commit into
mainfrom
jfversluis-fix-windows-notification-registration

Conversation

@jfversluis

Copy link
Copy Markdown
Member

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 NotificationInvoked after Register() throws COMException 0x80070490 because 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 after Register() succeeds, and a finally block removes the handler whenever registration fails, including the already-handled .NET 11 0x8007007E Insights 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 AppBuilderExtensionsTests suite 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

Additional 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.

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>
Copilot AI lite review requested due to automatic review settings September 3, 2026 07:10

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

🔵 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 NotificationInvoked before Register() to satisfy Windows App SDK requirements.
  • Track registration success locally and reliably unsubscribe the handler in a finally block when registration fails (including the known .NET 11 0x8007007E module-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.

@jfversluis
jfversluis marked this pull request as ready for review September 3, 2026 12:03
@jfversluis

Copy link
Copy Markdown
Member Author

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.

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 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

@TheCodeTraveler
TheCodeTraveler enabled auto-merge (squash) September 3, 2026 15:48
@TheCodeTraveler
TheCodeTraveler merged commit 28a12eb into main Sep 3, 2026
11 checks passed
@TheCodeTraveler
TheCodeTraveler deleted the jfversluis-fix-windows-notification-registration branch September 3, 2026 15:48
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 5, 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