maui: Running installed .NET MAUI Blazor app fails on Windows

Description

Running an installed .NET MAUI Blazor app on Windows fails with the following error:

Unhandled exception at 0x00000251D0338198 (Microsoft.ui.xaml.dll) in MauiApp7.exe: 0xC000027B: An application-internal exception has occurred (parameters: 0x00000251E04ECF80, 0x0000000000000002).

With some help from some folks on the WDX team I confirmed that the error is coming from a E_PATHNOTFOUND in Application.OnLaunched, presumably related to the HostPage of the BlazorWebView.

The installed app under \Program Files\WindowsApps does appear to have the correct wwwroot folder and static files.

The app also runs fine in development from VS. It’s only after publishing and installing the app that it fails.

Steps to Reproduce

  1. Create a .NET MAUI Blazor project
  2. Publish the project for Windows: msbuild /restore /t:Publish /p:TargetFramework=net6.0-windows10.0.19041 /p:configuration=release /p:GenerateAppxPackageOnBuild=true /p:AppxPackageSigningEnabled=true /p:PackageCertificateThumbprint="<Cert Thumbprint>" /p:PackageCertificatePassword="<Cert Password>". See steps for creating a signing cert
  3. Run the generated .msix installer to install the app and run it (to install the msix you may need to install the App Installer app from the Microsoft Store).

Expected result: App runs fine Actual result: App fails to start. Error in the Application event log.

Version with bug

Preview 13 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

Windows

Did you find any workaround?

Workarounds: Removing the HostPage property from the BlazorWebView. The app will then run, but of course the Blazor content won’t show up.

Relevant log output

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 6
  • Comments: 26 (19 by maintainers)

Most upvoted comments

Question, what is the guidance/pattern for a Maui app that incorporates a SQLite DB for offline capability? I.E, being able to write to files within program files\windows Apps? Do we suggest moving the SQLite DB and any other writable files outside of this folder structure, and if so , what is the recommended practice?

This is a quick workaround that can be placed in the project file

	<Target Name="_RemoveStaticWebAssetsDevelopmentManifest" BeforeTargets="GetCopyToOutputDirectoryItems">
		<!-- Remove the development manifest from the output since its not used and it will otherwise get incorrectly loaded in production. -->
		<ItemGroup>
			<ContentWithTargetPath Remove="$(StaticWebAssetDevelopmentManifestPath)" />
		</ItemGroup>
	</Target>

If I copy the app out of \Program Files\WindowsApp to somewhere else and try to run it, it fails to start earlier in the process due to this error:

Exception Info: System.DllNotFoundException: Unable to load DLL 'Microsoft.ui.xaml.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)
   at MauiApp7.WinUI.Program.XamlCheckProcessRequirements()
   at MauiApp7.WinUI.Program.Main(String[] args)

The issue is still here for some computers. Just to mention there are two errors in the event log. One is Faulting application just like described above and the other is

The process was terminated due to an unhandled exception. Exception Info: System.DllNotFoundException: Unable to load DLL ‘Microsoft.ui.xaml.dll’ or one of its dependencies: The specified module could not be found. (0x8007007E)

@javiercn Thanks for sharing. This quick workaround does work on developer’s computers. But it doesn’t seem to work on non-dev computers.

Faulting application name: MauiClient.exe, version: 1.0.0.0, time stamp: 0x6216d2c0 Faulting module name: KERNELBASE.dll, version: 10.0.19041.1466, time stamp: 0xe01c7650 Exception code: 0xc000027b Fault offset: 0x000000000010b362 Faulting process id: 0x38f4 Faulting application start time: 0x01d8445ddd96ae2b Faulting application path: C:\Program Files\WindowsApps\6772ECE0-9A8C-4587-AC4A-20F9A1984BE9_1.0.0.0_x64__9zz4h110yvjzm\MauiClient.exe Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll Report Id: fd8d0619-8bd8-409e-9e91-109db3982a90 Faulting package full name: 6772ECE0-9A8C-4587-AC4A-20F9A1984BE9_1.0.0.0_x64__9zz4h110yvjzm Faulting package-relative application ID: App

Got this to work, the issue is with how we use some of the Win UI APIs

image

This is the app deployed on a separate machine

I’m trying to package our .NET MAUI Blazor application to distribute it for internal testing. The installation on my dev machine is working. I followed the instructions of @SteveSandersonMS. Nothing happens when I start the application. The following message can be found in an Application Error in the Event Viewer:

Faulting application name: Hygrosoft.exe, version: 1.0.0.0, time stamp: 0x61e1d8d9 Faulting module name: KERNELBASE.dll, version: 10.0.19041.1503, time stamp: 0xb2acaea9 Exception code: 0xc000027b Fault offset: 0x000000000010b382 Faulting process id: 0x6130 Faulting application start time: 0x01d8352944f3fcd3 Faulting application path: C:\Program Files\WindowsApps\Rotronic.Hygrosoft_1.0.0.0_x64__0j3cv4mjdecbg\Hygrosoft.exe

I would be very happy if there was a fix for that. We can’t test the application otherwise.

One indication would be what happens if you copy the application out of Program Files and into your user directory. If it can run from your user directory but not from Program Files, then it’s probably the same as #4151 (i.e., a permissions issue whereby webview2 can’t create its own temporary files in the application directory).