WindowsAppSDK icon indicating copy to clipboard operation
WindowsAppSDK copied to clipboard

Unpackaged x64 C++ WinUI application fails with "Access is denied"

Open torleifat opened this issue 3 years ago • 13 comments

Describe the bug

I created a new WinUI project and converted it to unpackaged using this guide. I made no other modifications and attempted to start it which resulted in the following messages:

\dev\WindowsAppRuntime_BootstrapDLL\MddBootstrap.cpp(373)\Microsoft.WindowsAppRuntime.Bootstrap.dll!00007FFBF53880CF: (caller: 00007FFBF53871DB) Exception(1) tid(429c) 80070005 Access is denied. Msg:[Error in LoadLibrary: 5 (0x5) loading C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.2_2000.707.2303.0_x64__8wekyb3d8bbwe\Microsoft.WindowsAppRuntime.dll] CallContext:[\Initialize] Exception thrown at 0x00007FFC1E76CD29 in MiraQ.exe: Microsoft C++ exception: wil::ResultException at memory location 0x0000001C186FCB80. Exception thrown at 0x00007FFC1E76CD29 in MiraQ.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000. \dev\WindowsAppRuntime_BootstrapDLL\MddBootstrap.cpp(213)\Microsoft.WindowsAppRuntime.Bootstrap.dll!00007FFBF539BB71: (caller: 00007FFBF5386E09) ReturnHr(1) tid(429c) 80070005 Access is denied. Msg:[\dev\WindowsAppRuntime_BootstrapDLL\MddBootstrap.cpp(373)\Microsoft.WindowsAppRuntime.Bootstrap.dll!00007FFBF53880CF: (caller: 00007FFBF53871DB) Exception(1) tid(429c) 80070005 Access is denied. Msg:[Error in LoadLibrary: 5 (0x5) loading C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.2_2000.707.2303.0_x64__8wekyb3d8bbwe\Microsoft.WindowsAppRuntime.dll] CallContext:[\Initialize] ] CallContext:[\Initialize] \dev\WindowsAppRuntime_BootstrapDLL\MddBootstrap.cpp(166)\Microsoft.WindowsAppRuntime.Bootstrap.dll!00007FFBF5386EF7: (caller: 00007FF63C20B72C) ReturnHr(2) tid(429c) 80070005 Access is denied. CallContext:[\Initialize]

WinAppSDK nuget version: 1.2.221209.1 WinAppSDK runtime: 1.2.221209.1

This does work if I build and run it as x86.

I tried to reinstall the runtimes in case I had an old version laying around that was causing trouble. This is the 1.2X appruntime I have installed now:

Microsoft.WindowsAppRuntime.1.2_2000.707.2303.0_x64__8wekyb3d8bbwe Microsoft.WindowsAppRuntime.1.2_2000.707.2303.0_x86__8wekyb3d8bbwe MicrosoftCorporationII.WinAppRuntime.Main.1.2_2000.707.2303.0_x64__8wekyb3d8bbwe MicrosoftCorporationII.WinAppRuntime.Singleton_2000.707.2303.0_x64__8wekyb3d8bbwe Microsoft.WinAppRuntime.DDLM.2000.707.2303.0-x6_2000.707.2303.0_x64__8wekyb3d8bbwe Microsoft.WinAppRuntime.DDLM.2000.707.2303.0-x8_2000.707.2303.0_x86__8wekyb3d8bbwe

Steps to reproduce the bug

  1. Create a new Blank App, Packaged.
  2. Convert it to Unpackaged using this guide.
  3. Attempt to debug it in x64

Expected behavior

I would expect there to be not be any Access is Denied message.

Screenshots

No response

NuGet package version

Windows App SDK 1.2.2: 1.2.221209.1

Packaging type

Unpackaged

Windows version

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

IDE

Visual Studio 2022

Additional context

No response

torleifat avatar Jan 04 '23 09:01 torleifat

Hmm, I do remember seeing YourPhone being in the paths that the Windows App SDK libraries are being loaded from again. I wonder if this is the same Windows 10 bug.

DarranRowe avatar Jan 04 '23 20:01 DarranRowe

I have the same issue with C# WinUI 3 application. It works as x86 and crashes as x64.

alkalinin avatar Jan 06 '23 12:01 alkalinin

I also have a similar problem with Microsoft.ui.xaml.dll (E_ACCESSDENIED) with unpackaged x64 (with Windows App SDK 1.1.0) The only workaround I found atm is to add

<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>

castorix avatar Jan 06 '23 15:01 castorix

\dev\WindowsAppRuntime_BootstrapDLL\MddBootstrap.cpp(373)\Microsoft.WindowsAppRuntime.Bootstrap.dll!00007FFBF53880CF: (caller: 00007FFBF53871DB) Exception(1) tid(429c) 80070005 Access is denied. Msg:[Error in LoadLibrary: 5 (0x5) loading C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.2_2000.707.2303.0_x64__8wekyb3d8bbwe\Microsoft.WindowsAppRuntime.dll] CallContext:[\Initialize] Exception thrown at 0x00007FFC1E76CD29 in MiraQ.exe: Microsoft C++ exception: wil::ResultException at memory location 0x0000001C186FCB80. Exception thrown at 0x00007FFC1E76CD29 in MiraQ.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.

That's surprising.

Your app's running as MediumIL (not elevated, LowIL or AppContainer)?

Can you provide the ACLs for your exe and that dll e.g.

ICACLS C:\Foo\Bar.exe
ICACLS "C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.2_2000.707.2303.0_x64__8wekyb3d8bbwe\Microsoft.WindowsAppRuntime.dll"

That may provide a hint to the root issue

+@bpulliam @Scottj1s @MikeHillberg

DrusTheAxe avatar Jan 06 '23 16:01 DrusTheAxe

\dev\WindowsAppRuntime_BootstrapDLL\MddBootstrap.cpp(373)\Microsoft.WindowsAppRuntime.Bootstrap.dll!00007FFBF53880CF: (caller: 00007FFBF53871DB) Exception(1) tid(429c) 80070005 Access is denied. Msg:[Error in LoadLibrary: 5 (0x5) loading C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.2_2000.707.2303.0_x64__8wekyb3d8bbwe\Microsoft.WindowsAppRuntime.dll] CallContext:[\Initialize] Exception thrown at 0x00007FFC1E76CD29 in MiraQ.exe: Microsoft C++ exception: wil::ResultException at memory location 0x0000001C186FCB80. Exception thrown at 0x00007FFC1E76CD29 in MiraQ.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.

That's surprising.

Your app's running as MediumIL (not elevated, LowIL or AppContainer)?

Can you provide the ACLs for your exe and that dll e.g.

ICACLS C:\Foo\Bar.exe
ICACLS "C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.2_2000.707.2303.0_x64__8wekyb3d8bbwe\Microsoft.WindowsAppRuntime.dll"

That may provide a hint to the root issue

+@bpulliam @Scottj1s @MikeHillberg

It should be MediumIL as far as I can tell.

ICACLS .\App4.exe
.\App4.exe NT AUTHORITY\SYSTEM:(I)(F)
           BUILTIN\Administrators:(I)(F)
           [My user]:(I)(F)

and

ICACLS "C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.2_2000.707.2303.0_x64__8wekyb3d8bbwe\Microsoft.WindowsAppRuntime.dll"
C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.2_2000.707.2303.0_x64__8wekyb3d8bbwe\Microsoft.WindowsAppRuntime.dll NT AUTHORITY\SYSTEM:(F)

        APPLICATION PACKAGE AUTHORITY\ALL APPLICATION PACKAGES:(RX)

        APPLICATION PACKAGE AUTHORITY\ALL RESTRICTED APPLICATION PACKAGES:(RX)

        NT AUTHORITY\LOCAL SERVICE:(RX)

        NT AUTHORITY\NETWORK SERVICE:(RX)

        NT SERVICE\TrustedInstaller:(F)

        S-1-15-3-1024-3635283841-2530182609-996808640-1887759898-3848208603-3313616867-983405619-2501854204:(RX)

        BUILTIN\Users:(R)

        BUILTIN\Users:(Rc,S,RD,REA,X,RA)

        BUILTIN\Users:(Rc,S,RD,REA,X,RA)

        BUILTIN\Users:(Rc,S,RD,REA,X,RA)

        NT AUTHORITY\RESTRICTED:(RX)

        S-1-19-512-4096:(I)(RX,D,WDAC,WO,WA)

Successfully processed 1 files; Failed processing 0 files

torleifat avatar Jan 06 '23 16:01 torleifat

I've been informed ICACLS doesn't report Conditional ACEs. Please run the same commands but with CACLS path /s for a more complete ACL e.g.

CACLS "C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.2_2000.707.2303.0_x64__8wekyb3d8bbwe\Microsoft.WindowsAppRuntime.dll" /s

DrusTheAxe avatar Jan 07 '23 04:01 DrusTheAxe

Hello,

I think I also have the same issue (but for C#): The VS debug output shows the following message: The program '[2160] App.exe' has exited with code 2147942405 (0x80070005). In the event viewer, I have this entry:

General Tab: Access is denied Details: Windows App Runtime ERROR 0x80070005: Bootstrapper initialization failed while looking for version 1.2 (MSIX package version >= 2000.707.2303.0)

Here is the result of the CACLS command:

CACLS "C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.2_2000.707.2303.0_x64__8wekyb3d8bbwe\Microsoft.WindowsAppRuntime.dll" /s
C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.2_2000.707.2303.0_x64__8wekyb3d8bbwe\Microsoft.WindowsAppRuntime.dll "D:PAI(A;;0x1200a9;;;AC)(A;;FA;;;SY)(A;;0x1200a9;;;S-1-15-2-2)(A;;0x1200a9;;;LS)(A;;0x1200a9;;;NS)(A;;FA;;;S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464)(A;;0x1200a9;;;S-1-15-3-1024-3635283841-2530182609-996808640-1887759898-3848208603-3313616867-983405619-2501854204)(A;;FR;;;BU)(XA;;0x1200a9;;;BU;(Exists WIN://PKG))(XA;;0x1200a9;;;BU;(WIN://SYSAPPID Contains "Microsoft.WindowsAppRuntime.1.2_8wekyb3d8bbwe"))(XA;;0x1200a9;;;BU;(WIN://SYSAPPID Contains "Microsoft.YourPhone_8wekyb3d8bbwe"))(A;;0x1200a9;;;RC)"

And here the installed packages:

PS C:\Windows\system32> $(get-appxpackage micro*win*appruntime*).packagefullname                                        Microsoft.WindowsAppRuntime.1.2_2000.707.2303.0_x64__8wekyb3d8bbwe
Microsoft.WindowsAppRuntime.1.2_2000.707.2303.0_x86__8wekyb3d8bbwe
MicrosoftCorporationII.WinAppRuntime.Main.1.2_2000.707.2303.0_x64__8wekyb3d8bbwe
MicrosoftCorporationII.WinAppRuntime.Singleton_2000.707.2303.0_x64__8wekyb3d8bbwe
Microsoft.WinAppRuntime.DDLM.2000.707.2303.0-x6_2000.707.2303.0_x64__8wekyb3d8bbwe
Microsoft.WinAppRuntime.DDLM.2000.707.2303.0-x8_2000.707.2303.0_x86__8wekyb3d8bbwe

Thank you

phiwhynot avatar Jan 09 '23 07:01 phiwhynot

Here's what CACLS gives me:

CACLS "C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.2_2000.707.2303.0_x64__8wekyb3d8bbwe\Microsoft.WindowsAppRuntime.dll" /s

C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.2_2000.707.2303.0_x64__8wekyb3d8bbwe\Microsoft.WindowsAppRuntime.dll "D:PAI(A;;FA;;;SY)(A;;0x1200a9;;;AC)(A;;0x1200a9;;;S-1-15-2-2)(A;;0x1200a9;;;LS)(A;;0x1200a9;;;NS)(A;;FA;;;S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464)(A;;0x1200a9;;;S-1-15-3-1024-3635283841-2530182609-996808640-1887759898-3848208603-3313616867-983405619-2501854204)(A;;FR;;;BU)(XA;;0x1200a9;;;BU;(Exists WIN://PKG))(XA;;0x1200a9;;;BU;(WIN://SYSAPPID Contains "Microsoft.WindowsAppRuntime.1.2_8wekyb3d8bbwe"))(XA;;0x1200a9;;;BU;(WIN://SYSAPPID Contains "Microsoft.YourPhone_8wekyb3d8bbwe"))(A;;0x1200a9;;;RC)"

torleifat avatar Jan 09 '23 07:01 torleifat

@sachintaMSFT is this due to the same issue as https://github.com/microsoft/WindowsAppSDK/issues/3137#issuecomment-1332851404 (Windows 10 needs the servicing update coming in Jan)?

Is that update available yet? How can one detect if they have it installed?

DrusTheAxe avatar Jan 30 '23 19:01 DrusTheAxe

The bug is still there for me with unpackaged C# app. Fully patched Windows 10 22H2 (10.0.19045.2604)

przemsen avatar Feb 21 '23 08:02 przemsen

I can confirm that while the #3137 has been fixed for packaged apps with recent Windows 10 updates, unfortunately the issue persists for unpackaged apps, though only some machines seem to be affected for us.

Searching for the error code "0x80070005" in issues here shows that many users are running into this, and unfortunately none of the issues have a solution nor do they seem to have gotten much attention from MS recently: https://github.com/microsoft/WindowsAppSDK/search?q=0x80070005&type=issues

@DrusTheAxe @sachintaMSFT @MagicAndre1981 is this being looked into and can you give any update? It seems like this should be treated as a P1 issue, as it essentially prevents using the SDK in an unpackaged app. We’d be happy to provide any further info that could help track this down.

triplef avatar Feb 21 '23 09:02 triplef

I have no idea, MAUI still requires some work for unpacked apps so I actually don't use this.

MagicAndre1981 avatar Feb 21 '23 09:02 MagicAndre1981

The error still occurs on Win10 22H2 (no problem on Win11) with App SDK 1.6. Any new information on this?

KaiserMarvin avatar Sep 19 '24 08:09 KaiserMarvin

/feedbackHub

ssparach avatar Jul 03 '25 22:07 ssparach

Hi @@torleifat. Please file this issue on Feedback Hub [Windows]+[f] and paste the link here so we can more easily find your information on the back end. The link can be found at the bottom of the feedback report. Please use "Developer Platform" and "Windows App SDK" for the Category.