microsoft-ui-xaml
microsoft-ui-xaml copied to clipboard
WinUI 3 application throwing 'Reentrancy was detected in this XAML application'
Describe the bug
A WinUI 3 application is throwing the following exception while running:
'Reentrancy was detected in this XAML application. Use a debugger to locate the reentrant code and, if necessary, move that code to an asynchronous event handler. Press OK to exit the application.'.
The UI contains minimum XAML components, but we couldn't find the reason behind the exception. The exception is not reproducible every time, but it is not rare (~ 1/10). Is there any way to fix this issue or is there any workaround available?
Steps to reproduce the bug
-
Create a C++ WinUI3 project using "Blank App, Packaged (WinUI 3 in Desktop)" template.
-
Make it as unpackaged application using the steps described in the following link. https://learn.microsoft.com/en-us/windows/apps/winui/winui3/create-your-first-winui3-app#unpackaged-create-a-new-project-for-an-unpackaged-c-or-c-winui-3-desktop-app
-
Replace the Main Window XAML code with following XAML.
-
Build the application.
-
Run the application in Visual Studio and observe the output window, or run the application without debugging mode and the application will be crashed.
Expected behavior
The application should run without any exception or crash.
Screenshots
Exception message in output window.
NuGet package version
Windows App SDK 1.4.1: 1.4.230913002
Packaging type
Packaged (MSIX), Unpackaged
Windows version
Windows 10 version 22H2 (19045, 2022 Update)
IDE
Visual Studio 2022
Additional context
An unpackaged sample application with given issue is attached. SampleApp.zip
Any help would be greatly appreciated.