WinUI 3 published unpackaged self-contained app crashes immediately (Microsoft.UI.Xaml.dll 0xc000027b)

Nikita Kuptsov 20 Reputation points
2026-08-06T17:51:54.88+00:00

Description

A brand-new WinUI 3 application crashes immediately after publishing.

The same project works correctly in Debug and Release. The problem only occurs with the published application.

Environment

  • Visual Studio 2025 18.8.2
  • .NET SDK 10.0.302
  • Windows App SDK 2.2.0 (also reproduced with 2.3.1)
  • Microsoft.Windows.SDK.BuildTools 10.0.28000.2526 (also tested with 10.0.28000.2270)
  • Windows 11

Reproduction

  1. Create a new Blank App, Packaged (WinUI 3 in Desktop).
  2. Configure it as an unpackaged, self-contained application (WindowsPackageType=None).
  3. Publish to a folder.
  4. Run the published executable.

Expected behavior

The application starts normally.

Actual behavior

The published executable starts and immediately exits without showing any UI.

Windows Event Viewer reports:

Faulting module: Microsoft.UI.Xaml.dll
Exception code: 0xc000027b

Additional information

  • Debug works.
  • Release works.
  • Only the published application fails.
  • Reproduced on two different PCs.
  • Reproduced with a completely new WinUI 3 project.
  • Tried different versions of Microsoft.WindowsAppSDK and Microsoft.Windows.SDK.BuildTools.
  • Tried both Visual Studio Publish and dotnet publish.

    Description

    A brand-new WinUI 3 application crashes immediately after publishing. The same project works correctly in Debug and Release. The problem only occurs with the published application.

    Environment

    • Visual Studio 2025 18.8.2
    • .NET SDK 10.0.302
    • Windows App SDK 2.2.0 (also reproduced with 2.3.1)
    • Microsoft.Windows.SDK.BuildTools 10.0.28000.2526 (also tested with 10.0.28000.2270)
    • Windows 11

    Reproduction

    1. Create a new Blank App, Packaged (WinUI 3 in Desktop).
    2. Configure it as an unpackaged, self-contained application (WindowsPackageType=None).
    3. Publish to a folder.
    4. Run the published executable.

    Expected behavior

    The application starts normally.

    Actual behavior

    The published executable starts and immediately exits without showing any UI. Windows Event Viewer reports:
      Faulting module: Microsoft.UI.Xaml.dll
    

Exception code: 0xc000027b

  
  ## Additional information

  - Debug works.
  
  - Release works.
  
  - Only the published application fails.
  
  - Reproduced on two different PCs.
  
  - Reproduced with a completely new WinUI 3 project.
  
  - Tried different versions of `Microsoft.WindowsAppSDK` and `Microsoft.Windows.SDK.BuildTools`.
  
  - Tried both Visual Studio Publish and `dotnet publish`.
  
Windows development | WinUI
0 comments No comments

Answer accepted by question author
Jay Pham (WICLOUD CORPORATION) 4,435 Reputation points Microsoft External Staff Moderator
2026-08-07T00:32:48.16+00:00

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:

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

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

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.