maui: Failing module Microsoft.ui.xaml.dll

Description

When running an app deployed with msix, the app crashes (see log output).

I tried many combinations of project properties, here is the current one:

  <!--WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained-->
  <!--WinUISDKReferences>false</WinUISDKReferences-->
  <!--SelfContained>true</SelfContained-->

  <GenerateAppxPackageOnBuild>true</GenerateAppxPackageOnBuild>

I also tried to add package dependencies in appxmanifest, here is the current one:

  <Dependencies>
    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
    <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
	<PackageDependency Name="Microsoft.WindowsAppRuntime.1.1" MinVersion="1004.584.2120.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
	<PackageDependency Name="Microsoft.VCLibs.140.00.UWPDesktop" MinVersion="14.0.30035.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"/>
	<PackageDependency Name="Microsoft.UI.Xaml.2.7" MinVersion="7.2208.15002.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"/>
  </Dependencies>

I see that only Microsoft.WindowsAppRuntime.1.1.msix is copied in AppPackage/MyApp/Dependencies. I don’t know if it’s normal.

The app was deployed with the following command:

dotnet publish -c Release -f net6.0-windows10.0.19041.0 -p:Platform=x64

I don’t reproduce with the simple MAUI template project, so I suppose it comes from my package references:

	<ItemGroup>
		<PackageReference Include="Humanizer.Core.fr" Version="2.14.1" />
		<PackageReference Include="Plugin.LocalNotification" Version="10.0.1" />
		<PackageReference Include="System.Text.Json" Version="6.0.5" />
	  <PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
		<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
		<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
		<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
	
		<PackageReference Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'" Include="Microsoft.WindowsAppSDK" Version="1.1.4">
			<!--IncludeAssets>build</IncludeAssets-->
		</PackageReference>
	</ItemGroup>

Steps to Reproduce

  1. Publish the MAUI app

dotnet publish -c Release -f net6.0-windows10.0.19041.0 -p:Platform=x64

  1. Intall from msix or Install.ps1
  2. Run it from start menu
  3. The app crashes (from event log)

Link to public reproduction project repository

https://github.com/sinsedrix/NoRepo

Version with bug

6.0.486 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

Windows 11 Pro, Windows 10 Enterprise

Did you find any workaround?

No

Relevant log output

Event log:

Nom de l’application défaillante MyApp.Maui.exe, version : 4.2.0.0, horodatage : 0x62cf0990
Nom du module défaillant : Microsoft.ui.xaml.dll, version : 3.0.0.2208, horodatage : 0x8d698c4e
Code d’exception : 0xc000027b
Décalage d’erreur : 0x000000000033eda6
ID du processus défaillant : 0x3a18
Heure de début de l’application défaillante : 0x01d8bdd3d8b82617
Chemin d’accès de l’application défaillante : C:\Program Files\WindowsApps\fr.myapp_4.2.0.0_x64__132r1tgtcmz60\MyApp.Maui.exe
Chemin d’accès du module défaillant: C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.1_1004.584.2120.0_x64__8wekyb3d8bbwe\Microsoft.ui.xaml.dll
ID de rapport : c23cf8e7-e17a-4af6-adb9-0ea7714d1b17
Nom complet du package défaillant : fr.myapp_4.2.0.0_x64__132r1tgtcmz60
ID de l’application relative au package défaillant : App


WinDbg stack:

[0x0]   KERNELBASE!RaiseFailFastException + 0x152   
[0x1]   combase!RoFailFastWithErrorContextInternal2 + 0x4d9   
[0x2]   Microsoft_ui_xaml!DirectUI::FrameworkApplication::StartDesktop + 0x17c3ba   
[0x3]   Microsoft_ui_xaml!DirectUI::FrameworkApplicationFactory::Start + 0x63   
[0x4]   0x7ffd69a93a4d   
[0x5]   Microsoft_WinUI!ABI.Microsoft.UI.Xaml.IApplicationStaticsMethods.Start + 0x102   
[0x6]   Microsoft_WinUI!Microsoft.UI.Xaml.Application.Start + 0x2a   
[0x7]   MyApp_Maui!MyApp.Maui.WinUI.Program.Main + 0x179   
[0x8]   coreclr!CallDescrWorkerInternal + 0x83   
[0x9]   coreclr!MethodDescCallSite::CallTargetWorker + 0x176   
[0xa]   coreclr!MethodDescCallSite::Call + 0xb   
[0xb]   coreclr!RunMainInternal + 0x11f   
[0xc]   coreclr!RunMain + 0xd2   
[0xd]   coreclr!Assembly::ExecuteMainMethod + 0x1c9   
[0xe]   coreclr!CorHost2::ExecuteAssembly + 0x1c6   
[0xf]   coreclr!coreclr_execute_assembly + 0xe2   
[0x10]   hostpolicy!coreclr_t::execute_assembly + 0x2a   
[0x11]   hostpolicy!run_app_for_context + 0x56b   
[0x12]   hostpolicy!run_app + 0x3c   
[0x13]   hostpolicy!corehost_main + 0x107   
[0x14]   hostfxr!execute_app + 0x2e9   
[0x15]   hostfxr!`anonymous namespace'::read_config_and_execute + 0xa6   
[0x16]   hostfxr!fx_muxer_t::handle_exec_host_command + 0x161   
[0x17]   hostfxr!fx_muxer_t::execute + 0x482   
[0x18]   hostfxr!hostfxr_main_startupinfo + 0xab   
[0x19]   apphost!exe_start + 0x8d8   
[0x1a]   apphost!wmain + 0xab   
[0x1b]   apphost!invoke_main + 0x22   
[0x1c]   apphost!__scrt_common_main_seh + 0x10c   
[0x1d]   KERNEL32!BaseThreadInitThunk + 0x10   
[0x1e]   ntdll!RtlUserThreadStart + 0x2b

VS bug #1867112

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 28 (14 by maintainers)

Most upvoted comments

I found multiple origins for my issue:

  1. I was trying to write my appsettings.json in the app directory which was forbidden. => I moved appsettings from Path.GetDirectoryName(CurrentProcess.MainModule.FileName) to FileSystem.AppDataDirectory
  2. The package dependency on Microsoft.UI.Xaml is not needed as it’s included with Microsoft.WindowsAppRuntime dependency
  3. The package dependency on Microsoft.VCLibs is not copied in the AppPackage output directory => For the moment, I copy it manually:
  • Dependencies\x64\Microsoft.VCLibs.x64.14.00.Desktop.appx
  • Dependencies\x86\Microsoft.VCLibs.x86.14.00.Desktop.appx

I hope, it will be fixed soon.

again, make sure you handle exceptions correctly because unhandled exception handler is broken in WinUI

Ok, solved my issue. May not have been the same as the original post. I suspect for myself it was more due to the unhandled exception handler mentioned by @MagicAndre1981

I had been using a reference a static content file under the AppContext.BaseDirectory folder that requires creating a directory there, which is not possible with MSIX. Using FileSystem.Current.AppDataDirectory resolved the issue.

this shows that you get Stowed Exceptions (those 0xC000027B exceptions). I posted here how to analyze it

https://github.com/dotnet/maui/issues/7473#issuecomment-1140258629

Here is the Windows Event Viewer content. As for the dump files, there really was not any sort of information not contained in the original post here.

Faulting application name: my-apps-mobile.exe, version: 2.10.0.0, time stamp: 0x62cf0990 Faulting module name: Microsoft.ui.xaml.dll, version: 3.0.0.2208, time stamp: 0x8d698c4e Exception code: 0xc000027b Fault offset: 0x000000000033eda6 Faulting process id: 0x14c8 Faulting application start time: 0x01d8bf02cba567dd Faulting application path: C:\Program Files\WindowsApps\6B03B412-AC8B-4BEC-8788-0FDDE9980FE3_2.1.6.0_x64__esg7g11712y3c\my-apps-mobile.exe Faulting module path: C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.1_1004.584.2120.0_x64__8wekyb3d8bbwe\Microsoft.ui.xaml.dll Report Id: 4f1f5312-73dd-47c3-9923-51f1169b1b7e Faulting package full name: 6B03B412-AC8B-4BEC-8788-0FDDE9980FE3_2.1.6.0_x64__esg7g11712y3c Faulting package-relative application ID: App

@mattleibow I have been following the guide you linked and believe I am experiencing the same issue. I am able to generate the MSIX package and install on a test machine. However when I try to launch the app it fails. I receive similar logs as to here as well as an entry in the Windows Event Viewer.