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

Peterjc 81 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 App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
741 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Castorix31 82,501 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)

    12 people found this answer helpful.