Unable to load DLL 'Microsoft.ui.xaml.dll' or one of its dependencies: Access is denied

Peterjc 91 Reputation points
2022-11-10T01:01:45.537+00:00

I am trying to get a WinUI3 app to run unpackaged.

I have addded the
<WindowsPackageType>None</WindowsPackageType><UseWinUI>true</UseWinUI>
into the project file, and also have

   <ItemGroup>  
       <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.1.5"/>              
       <PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.755" />  
       <Manifest Include="$(ApplicationManifest)" />  
     </ItemGroup>  

I can build this, and run it on my Win11 dev machine, however when tryin to test in a Window10 VM, it does not run, and I see the following in the Event Viewer

   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)  

I have installed

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

It looks similar to the discussion here (https://github.com/microsoft/WindowsAppSDK/issues/974) except mine error does have the
Access is denied
at the end.

I have tried everything in the above link , and nothing fixes this.

I am not sure where
Microsoft.ui.xaml.dll'`` is (it is not included in my built files); I do not know where to go to next.

   Does anyone have any ideas on how the diagnose this?  
     
   Thanks in advance
Windows development | Windows App SDK
{count} vote

1 answer

Sort by: Most helpful
  1. Castorix31 90,686 Reputation points
    2022-11-10T07:23:36.56+00:00

    Did you try in the project file :

    <WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>  
    

    (Microsoft.ui.xaml.dll is in C:\Program Files\WindowsApps\ + Microsoft.WindowsAppRuntime version directory)

    15 people found this answer helpful.

Your answer

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