pushNotificationManager.Register() fails with winrt::hresult_error 8007005
Registering push notifications sometimes fails.
It seems like something is changing the permissions on a Microsoft redistributable component to deny execution by normal user contexts!
We are testing the https://github.com/microsoft/WindowsAppSDK-Samples/tree/main/Samples/Notifications/Push/cpp-console-unpackaged project from WindowsAppSDK-Samples.
To get additional information we modified the line
pushNotificationManager.Register();
to
try {
pushNotificationManager.Register();
}
catch (const winrt::hresult_error& ex)
{
std::cout << "pushNotificationManager.Register() exception winrt::hresult_error " << std::hex << ex.code() << std::endl;
return -1;
}
When it fails, it prints
pushNotificationManager.Register() exception winrt::hresult_error 8007005
The error 0x80070005 seems to relates to permission denied to the cache files - but it doesn't give us much information about what we are doing wrong.
We have tried running Windows App SDK 1.5.4 installer windowsappruntimeinstall-x64.exe as an administrator but it does not fix it.
Uninstalling Windows App SDK Runtime with Add/Remove program or with powershell remove-appxpackage before the installer does not fix it either.
ProcMon shows that the problem occurs when trying to open PushNotificationsLongRunningTask.ProxyStub.dll for execution.
The permissions when everything works**:**
(output from cacls.exe)
C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.5_5001.159.55.0_x64__8wekyb3d8bbwe\PushNotificationsLongRunningTask.ProxyStub.dll
"D:AI
(A;ID;0x1200a9;;;AC)
(A;ID;0x1200a9;;;S-1-15-2-2)
(A;ID;0x1200a9;;;BU)
(A;ID;FA;;;S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464)
(A;ID;0x1200a9;;;S-1-15-3-1024-3635283841-2530182609-996808640-1887759898-3848208603-3313616867-983405619-2501854204)
(A;ID;FA;;;SY)
(A;ID;0x1200a9;;;LS)
(A;ID;0x1200a9;;;NS)
(A;ID;0x1200a9;;;RC)"
Permissions from the parent folder allow local user to execute the file, everything works.
Permissions when things fail**:**
(output from cacls.exe)
C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.5_5001.159.55.0_x64__8wekyb3d8bbwe\PushNotificationsLongRunningTask.ProxyStub.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.5_8wekyb3d8bbwe"))
(XA;;0x1200a9;;;BU;(WIN://SYSAPPID Contains "MicrosoftCorporationII.WinAppRuntime.Singleton_8wekyb3d8bbwe"))(A;;0x1200a9;;;RC)"
Permissions from the parent foder are blocked, new permissions explicitly set, local user cannot execute the file.
How does this happen, and what is the preferable way to deal with this?