Hi @Nikita Kuptsov ,
Hi Nikita,
I see the crash only happens with the published output while Debug and Release both work, so I suspect the publish profile settings rather than the Windows App SDK binaries themselves. The exception code 0xc000027b is a "stowed exception" wrapper; the real error is inside it, and the most common trigger for this exact pattern in WinUI 3 is a publish option that WinUI 3 does not support:
- Trimming
If your publish profile sets PublishTrimmed=true, the trimmer removes WinRT/XAML metadata that WinUI needs at runtime, and the app crashes immediately at startup. This is a documented known issue; Microsoft recommends setting PublishTrimmed to false for all build configurations in your project's .pubxml files. See the note in Test single-instancing via app deployment and the referenced microsoft-ui-xaml issue #9914.
If you do want trimming later, it requires specific configuration; see the CsWinRT Trimming / AOT support doc and Trim self-contained deployments and executables.
- Single-file publish
PublishSingleFile=true is not supported for WinUI 3; the native Windows App SDK dependencies must remain as separate files next to the exe. See Single-file EXE.
Recommended test
Please republish with these options disabled and run the output again:
dotnet publish -c Release -r win-x64 --self-contained true /p:PublishTrimmed=false /p:PublishSingleFile=false /p:PublishReadyToRun=false
Also confirm your .csproj contains both of these together; .NET self-contained alone is not enough for an unpackaged Windows App SDK app:
<WindowsPackageType>None</WindowsPackageType>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
The official configuration is documented in the self-contained deployment guide and this sample project file.
If the crash still occurs after disabling trimming and single-file publish, please share your FolderProfile.pubxml, your .csproj, and the WER crash report from Event Viewer so I can read the inner exception behind 0xc000027b.
If you found my response helpful or informative, I would greatly appreciate it if you could provide feedback by interacting with the system or leaving a comment below.
Thank you.