microsoft / WindowsAppSDK

The Windows App SDK empowers all Windows desktop apps with modern Windows UI, APIs, and platform features, including back-compat support, shipped via NuGet.
https://docs.microsoft.com/windows/apps/windows-app-sdk/
MIT License
3.84k stars 321 forks source link

Microsoft.Internal.FrameworkUdk.dll fails to dynamically load in call to PushNotificationManager.CreateChannelAsync from an upackaged app #3106

Open Javier-Novales opened 1 year ago

Javier-Novales commented 1 year ago

Describe the bug

I'm evaluating the Windows App SDK's Push Notification features for possible integration into an existing project. In doing so I'm running into an issue when calling PushNotificationManager.CreateChannelAsync.

I've debugged it to the point where I see that Microsoft.Internal.FrameworkUdk.dll is being delay loaded in order to call PushNotifications_CreateChannelWithRemoteIdentifier. The GetLastError from the LoadLibraryEx call is returning 5 which implies ACCESS_DENIED.

As a workaround, I copied Microsoft.Internal.FrameworkUdk.dll from it's installed location at C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.1_1005.616.1651.0_x64__8wekyb3d8bbwe to the bin folder for my project %USERPROFILE%\source\repos\BSNotifierConsole\BSNotifierConsole\bin\x64\Debug\net6.0-windows10.0.19041.0 and that worked.

Steps to reproduce the bug

  1. Create console app project (C# or C++)
  2. Call PushNotificationManager.CreateChannelAsync
  3. See Module Load failure

Expected behavior

PushNotificationManager.CreateChannelAsync would not cause a module load failure.

Screenshots

No response

NuGet package version

1.1.5

Packaging type

Unpackaged

Windows version

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

IDE

Visual Studio 2022

Additional context

No response

pmpurifoy commented 1 year ago

I've never seen this before @DrusTheAxe. Anything glaringly obvious that could be the issue?

DrusTheAxe commented 1 year ago

A symptom of the wrong-ACL problem? I don't know the latest status on that (resolved? pending? someting?). Talk to @MikeHillberg

Javier-Novales commented 1 year ago

If this is the issue you're referring to https://github.com/microsoft/WindowsAppSDK/issues/2918 then perhaps it's related. Here is the output from icacls:


C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.1_1005.616.1651.0_x64__8wekyb3d8bbwe\Microsoft.Internal.FrameworkUdk.dll
   APPLICATION PACKAGE AUTHORITY\ALL APPLICATION PACKAGES:(RX)
   NT AUTHORITY\SYSTEM:(F)
   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