microsoft / microsoft/WindowsAppSDK

`ToastNotificationManager.CreateToastNotifier()` crash the app if user change their username without signing out

Open
#4,981 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area-Notifications
Dominant language
C++
Stars
4.7k
Forks
471
Avg merge
3d 13h
Merged PRs (30d)
28

Description

### Describe the bug

My app recently get a user report of crashing. After checking the log, I found it crashes in toast notification related apis. His pc was connected to a domain, and has its username changed, without manual rebooting / manual signing out his account. Some quick experiment found out that if you launch the app first then change your username, calling `ToastNotificationManager.CreateToastNotifier()` will throw exception.

This is very corner case, but I think it should be documented (or don't throw exception). The majority of the WinRT api can still function normally in this case.

### Steps to reproduce the bug

1. Create a winui3 C++ app packaged
2. Use this code:
```cpp
void MainWindow::myButton_Click(IInspectable const&, RoutedEventArgs const&)
{
myButton().Content(box_value(L"Clicked"));

winrt::Windows::Data::Xml::Dom::XmlDocument doc;
doc.LoadXml(LR"(



Hello World
This is a simple toast message



)");
winrt::Windows::UI::Notifications::ToastNotification toast{ doc };

winrt::Windows::UI::Notifications::ToastNotificationManager::CreateToastNotifier()
.Show(toast);

MessageBox(NULL, L"", L"finished", 0);
}
```
3. Build and run the app
4. Change the username (you can simply run `netplwiz` to do that)
5. Click the button to send a toast, observe the crash

### Expected behavior

_No response_

### Screenshots

_No response_

### NuGet package version

Windows App SDK 1.6.3: 1.6.241114003

### Packaging type

Packaged (MSIX)

### Windows version

_No response_

### IDE

Visual Studio 2022

### Additional context

Windows 11 23H2

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the crash in a packaged WinUI 3 C++ app using ToastNotificationManager::CreateToastNotifier(), following the provided username-change steps on Windows 11 23H2. Investigate whether the behavior should be documented or changed so the call does not throw an exception; completion would require one of those outcomes to be established.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.