Hi @Hong ,
Having to force-stop the app instead of closing it normally interrupts your debugging workflow. The fact that the apps close normally without debugging narrows the investigation to shutdown with the debugger attached. The 0xC0000005 error is a native access violation, but the fault appearing in Microsoft.ui.xaml.dll does not by itself identify the component responsible.
I would first isolate Visual Studio's XAML debugging features. XAML Hot Reload supports WinUI 3 and can attach XAML tooling during F5 debugging, making it a useful comparison for the behavior you described. This does not yet establish that Hot Reload is causing the exception.
Use the same affected app, keeping its code, SDK version, and other debugger settings unchanged:
- Stop debugging, open
Tools > Options, and search forXAML. On theXAML Hot ReloadorXAML Diagnosticspage, temporarily clearEnable in-app toolbar. Start a new F5 session and close the window with X. - If the exception remains, stop debugging and temporarily clear
Enable XAML Hot Reload. If your Visual Studio uses the newerXAML Diagnosticspage, clearEnable for WinUI (including .NET MAUI)instead. Start another F5 session and repeat the close test. - If neither change helps, restore the original settings and try a fresh WinUI Blank App with the same Windows App SDK version, architecture, packaging type, and debugger settings.
If either of the first two tests allows normal shutdown, leaving the relevant feature disabled can provide a temporary workaround, with that XAML debugging functionality unavailable. If the Blank App also fails, the shared environment needs further investigation. If it closes normally, the next focus is the affected app's controls and shutdown code.
If an affected app still fails and uses WebView2, try a separate cleanup comparison with the original XAML debugging settings restored. Microsoft's WinUI 3 WebView2 sample calls WebView2.Close() in the window's Closed handler. Its comment describes a debug-time shutdown issue involving an expected winrt::hresult_error; it does not establish the cause of your access violation.
For a control named MyWebView, register this after InitializeComponent() in its owning window's constructor:
Closed += (_, _) =>
{
MyWebView?.Close();
};
Apply the cleanup to each WebView2 owned by the window. Skip this comparison if the app does not use WebView2.
Please share which test changes the behavior, your Visual Studio and Windows App SDK versions, whether the app is packaged or unpackaged, and whether it uses WebView2. If the Blank App also fails, please include your Windows build. A full debug log is not needed at this stage. If any of the options or steps are unclear, please let me know.