WindowsAppSDK icon indicating copy to clipboard operation
WindowsAppSDK copied to clipboard

NET6 and WindowsAppSDK1.0.3 continues to fail to start after install - Unable to load DLL 'Microsoft.ui.xaml.dll'

Open s3nt1n3l-hub opened this issue 2 years ago • 22 comments

Describe the bug

We are unable to install and run any WinUI3 applications when targeting .NET6. The application installs as expected, but when trying to open it - the following error is recorded in the Event Viewer.

Application: TestApp.exe
CoreCLR Version: 6.0.422.16404
.NET Version: 6.0.4
Description: 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)
   at TestApp.Program.XamlCheckProcessRequirements()
   at TestApp.Program.Main(String[] args) in C:\Users\s3nt1n3l-hub\source\repos\TestApp\TestApp\obj\x64\Release\net6.0-windows10.0.19041.0\win10-x64\App.g.i.cs:line 28

Steps to reproduce the bug

  1. Open VS2022 Pro (v17.1.6)
  2. Create a new 'Blank App, Packaged (WinUI3 in Desktop)' project
  3. Right click csproj file, select Publish
  4. Profile settings - Config: Release | x64, Target Framework: net6.0-windows10.0.19041.0, Deployment mode: Self-contained, Target runtime: win10-x64
  5. Publish
  6. Once published, install
  7. Try to open application

Nothing happens. Error above appears in Event Viewer.

Expected behavior

Expect application to run; a window with a single button stating 'Click me' should be visible.

Screenshots

No response

NuGet package version

1.0.0

Packaging type

Packaged (MSIX)

Windows version

Windows 10 version 21H2 (19044, November 2021 Update)

IDE

Visual Studio 2022

Additional context

No response

s3nt1n3l-hub avatar Apr 27 '22 10:04 s3nt1n3l-hub

@DefaultRyan, can you try the repro steps and see what's going on here?

BenJKuhn avatar May 02 '22 19:05 BenJKuhn

We've updated to WindowsAppSDK v1.1.0 and unfortunately this issue still persists.

s3nt1n3l-hub avatar Jun 08 '22 14:06 s3nt1n3l-hub

I've had a lot on my plate this last month, but I'll try to get some initial diagnosis happening this week.

DefaultRyan avatar Jun 08 '22 17:06 DefaultRyan

Same error for me targeting net6.0-windows10.0.17763.0 with MAUI image

anpin avatar Jun 09 '22 08:06 anpin

I had a fully working project; just putting the finishing touches on and visual studio restarted while debugging. Now I am stuck here... same as the screenshot above, but I did not change any code... Hard to explain how I went from '5 minutes til done" to "app wont start"...

edgaralenpwn avatar Jun 10 '22 21:06 edgaralenpwn

@edgaralenpwn I was actually able to overcome this issue (only to hit something else, yikes!) try to fully clear your project (remove bin and obj) and then do msbuild /t:Restore and msbuild /t:Build

anpin avatar Jun 11 '22 10:06 anpin

Do you have VCRedist installed?

d2dyno1 avatar Jun 12 '22 11:06 d2dyno1

Do you have VCRedist installed?

Well, I did not have it installed, and was pretty much done with app. I was just trying to fix some control placement with XAML hot reload. It was working for months, smoothly and correctly without the VCredist installed. (This is the machine I developed the app on, and once I finished up, I was able to create a app package and deploy to another computer, that computer also did not have VCRedist installed separately, though the app package may have included it, I didnt check. ) I started a new project and made sure the namespace and other important stuff matched, got all packages imported, ensured it worked without my code. Thankfully, I only had a handful of classes and controls, so I recreated them, with the same name, in the new project; selected my project, chose 'Add > UserControl' or Class, etc... I did this to ensure whatever was added by default for xmlns was intact and unedited. I then copied and pasted my class bodies into the new files and was able to compile and finish my app.

@anpin I wish I read your comment before I took the dive to just recreate the project.

edgaralenpwn avatar Jun 12 '22 16:06 edgaralenpwn

Do you have VCRedist installed?

We did have it installed (my previous installation was done on 27/05/22). However, as a sanity check this morning I uninstalled it and completed a clean installation again. Our (installed) app now seems to be working without issues! I'd assume something went wrong with the previous install, though it would be a little surprising as the same issue was replicated on three machines - all with the same versions/updates. Either way, we seem to be resolved for now; Thanks for the assist.

s3nt1n3l-hub avatar Jun 13 '22 07:06 s3nt1n3l-hub

Unfortunately spoke too soon - I re-published the solution ready to share the installation with a colleague and have the missing xaml.dll error once again.

The publish settings used are: ClickOnce Install location: From a CD, DVD, or USB drive Automatically check for updates: false Automatically increment version: false Sign the ClickOnce manifests: true (Create test certificate, using timestamp.digicert.com) Configuration: Release | x64 Target framework: net6.0-windows10.0.19041.0 Deployment mode: Self-contained Target runtime: x64 (not using Produce single file, when we do we receive a different error stating that the file Resources.pri has a different hash than the one found in the manifest)

Changing deployment mode to Framework-dependent just hangs on the publish and never completes.

Additional We have finally got a successful installation via sideloading instead. But we did find this process hung for 45 minutes - the solution was to close VS, reopen and run the publish immediately.

s3nt1n3l-hub avatar Jun 13 '22 09:06 s3nt1n3l-hub

This is like really really anoying. Trying to publish (packaged) and run the app with Selfcontained win10-64x, but keep getting the same error. Debugging the packaged WinUI3 application DOES work. Tried multiple suggested solutions (installed VCRedist, installed the Windows App SDK runtime downloads but nothing fixes the issue.

NicolasKlaas avatar Jul 21 '22 14:07 NicolasKlaas

This is like really really anoying. Trying to publish (packaged) and run the app with Selfcontained win10-64x, but keep getting the same error. Debugging the packaged WinUI3 application DOES work. Tried multiple suggested solutions (installed VCRedist, installed the Windows App SDK runtime downloads but nothing fixes the issue.

I use WinUi3 already in production, funny enough this issues appears only to happen on 5% of the customers, however I couldn't find any fix. Sometimes reinstalling windows fixed it.... I deploy unpackaged builds.

Funfact on one pc I installed Visual Studio with all dependencie and templates, it gets even on debug mode the "unable to load DLL" error :D

KenionX avatar Jul 22 '22 07:07 KenionX

I am running into this same issue except that I am on WindowsAppSDK 1.2 preview1. My app launches and works in debug mode, but as soon as I publish I get the missing dll error. I have the VCRedist & SDK runtime downloaded as well

lutzklai avatar Oct 28 '22 16:10 lutzklai

I am running into this same issue except that I am on WindowsAppSDK 1.2 preview1. My app launches and works in debug mode, but as soon as I publish I get the missing dll error. I have the VCRedist & SDK runtime downloaded as well

<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>

add that to your project, should fix all depedencie issues

KenionX avatar Nov 06 '22 22:11 KenionX

I am also getting a similar issue, though mine does report an "Access is denied". In my case I am building as an unpackaged, so added the following to the project file..

<WindowsPackageType>None</WindowsPackageType>
Application: MyApp.exe
CoreCLR Version: 6.0.1122.52304
.NET Version: 6.0.11
Description: 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: Access is denied. (0x80070005 (E_ACCESSDENIED))
   at MyApp.Program.XamlCheckProcessRequirements()
   at MyApp.Program.Main(String[] args)

The app run s fine on my dev machine, but not on a test VM.

I have installed all of

  • .net 6 runtime
  • Windows App SDK runtime
  • VC runtime

Microsoft.ui.xaml.dll is NOT in my build folder, but it is located in C:\Program Files\WindowsApps. I found I had no permissions on that folder, so added full permissions for Everyone, but still have the issue

pjc2007 avatar Nov 11 '22 00:11 pjc2007

I noticed WinApp 1.2 was now available, so I tried updating to this. I also installed the 1.2 version of the WinApp redist on my test VM

Now the app would load, however, as I want to check that the webview2 is also installed (which my app will use), I call

string version = CoreWebView2Environment.GetAvailableBrowserVersionString();

But this resulted in

 Message:System.TypeInitializationException: The type initializer for 'WinRT.ActivationFactory`1' threw an exception.
 ---> System.UnauthorizedAccessException: Access is denied. (0x80070005 (E_ACCESSDENIED))
   at WinRT.BaseActivationFactory..ctor(String typeNamespace, String typeFullName)
   at WinRT.ActivationFactory`1..ctor()
   at WinRT.ActivationFactory`1..cctor()
   --- End of inner exception stack trace ---
   at WinRT.ActivationFactory`1.As(Guid iid)
   at Microsoft.Web.WebView2.Core.CoreWebView2Environment.Make___objRef_global__Microsoft_Web_WebView2_Core_ICoreWebView2EnvironmentStatics()
   at Microsoft.Web.WebView2.Core.CoreWebView2Environment.get__objRef_global__Microsoft_Web_WebView2_Core_ICoreWebView2EnvironmentStatics()
   at Microsoft.Web.WebView2.Core.CoreWebView2Environment.GetAvailableBrowserVersionString()
   at MyApp.MainWindow.CheckWebview2Installed()

So once again a E_ACCESSDENIED error.

I then added the <WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained> into the project file, and the app now runs.

So there seems to be something with using a shared Windows App SDK runtime

pjc2007 avatar Nov 11 '22 02:11 pjc2007

I am also unable to run myApp.exe . this runs perfectly well under visual studio 2022 environment. My environment is : Visual studio 17.4.0 .Net Framework 7.0 The error I see on application log of event viewer is CoreCLR Version: 7.0.22.51805 .NET Version: 7.0.0 Description: 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)

when i use <WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained> in csproj file, then this restricts me to use only x64 platform After build the executable residing in /bin/x64/Release/Appx folder works but not which resides directly under /bin/x64/Release folder

Also I am unable to publish for x64 platform I have to provide installer to my testing team and i am unable to do so. let me know if you have solution available for this.

shantisharma avatar Feb 06 '23 13:02 shantisharma

Same issue. Tried a vanilla .Net MAUI app with no changes. Runs fine but once packaged, it fails with this error. Same with the app I'm working on today. Is this bug really still open after more than a year?

rayhayes avatar May 18 '23 23:05 rayhayes

Just got this error too on one of my users machine... My app is packaged.

bogdan-patraucean avatar May 28 '23 10:05 bogdan-patraucean

ITNOA

@DefaultRyan Any update?

soroshsabz avatar Jul 08 '23 10:07 soroshsabz

Have the same error.

  • .NET8.0
  • WindowsAppSDK 1.4

<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained> doesn't help

IvanMurzak avatar Jan 11 '24 00:01 IvanMurzak

@IvanMurzak

I had also Issues with

* `.NET8.0`

* `WindowsAppSDK 1.4`

Try to downgrade to 1.2. While keeping <WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>

This version was it to be exact

<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.2.230313.1" />

That worked for me at least.

silenterus avatar Jan 20 '24 19:01 silenterus