WindowsAppSDK
WindowsAppSDK copied to clipboard
Restart API not working with unpackaged apps in 1.1.3
Describe the bug
Official documents https://docs.microsoft.com/en-us/windows/apps/windows-app-sdk/stable-channel#app-lifecycle--restart mention this should work for packaged and unpackaged apps, but using
Microsoft.Windows.AppLifecycle.AppInstance.Restart("");
as described here https://github.com/microsoft/WindowsAppSDK/blob/main/specs/AppLifecycle/Restart/restartApi.markdown#new-api
just crashes the app.
Steps to reproduce the bug
Just use this sample to verify: TestRestartManager.zip
Expected behavior
No response
Screenshots
No response
NuGet package version
1.1.3
Packaging type
Unpackaged
Windows version
Windows 10 version 21H2 (19044, November 2021 Update)
IDE
Visual Studio 2022
Additional context
No response
It just crashes the whole application without getting a chance to debug even with native debugging enabled and all exceptions checked.
Once <WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
is set on the project you get a file not found exception. Turns out that RestartAgent.exe is not distributed:
@Balkoth thanks for providing the feedback. We will take a look at the issue and keep you posted on the updates
With Template Studio 5.2 using 1.1.3, Restart("")
works fine for me for both packaged and unpackaged projects. I do see a failure though when switching to self-contained. I get FileNotFound exceptions from the API which I assume is referring to RestartAgent.exe that you shared above.
https://task.ms/40728649
I can not confirm your observations. The attached sample was created with Template Studio 5.2 and does not ever restart. I can not find any relevant information on how to diagnose why. Eventlog does not show anything related in the Application log nor the AppLocker log.
My next guess would be that it's a downlevel problem since you're on 19044. @kanismohammed are these APIs supported downlevel?
My next guess would be that it's a downlevel problem since you're on 19044. @kanismohammed are these APIs supported downlevel?
@dhoehna - Can you please take a look?
It was already answered here: https://github.com/microsoft/WindowsAppSDK/issues/2792#issuecomment-1196793506
The restart agent isn't being included when WASDK is self-contained.
I can work on getting the restart agent to deploy with everything else.
Thanks. There are two issues though. The self-contained issue is one. It's also possible the Restart API doesn't work for unpackaged apps downlevel. We need to investigate.
Is there some more investigation ongoing or will this just be buried like all other bug reports?
I'm looking into it. Progress has been slow, that's all.
Sorry for the gap in communication. I'm reporting in that I did find the root cause of the issue.
The root cause of the issue is in the OS code. More research is needed to figure out where a fix should go. Most likely Windows App SDK.
Again, sorry for the delay in communication. It took a bit longer than expected to hunt down this issue.
@mikebattista We might need to add internal hours to find a fix for this issue. @kanismohammed FYI.
@dhoehna I've already filed https://task.ms/40728649. Do we need another bug?
Alrighty. Updating this. Sorry it took so long. The bug was deeper than I though.
This is a platform issue in VB. The ACLs on the folder in Windows Apps is Low IL. What this means is, even if the parent app is medium-IL, any process made in the frameworks folder, for example, RestartAgent.exe, "...\windowsapps[Fwp]\RestartAgent.exe" is lowIL.
Since restartAgent.exe creates the same process that was restarted, and, new processes inherit the parent processes IL, that means, the new process is also LowIL.
Now I'll be talking with peeps to figure out "What do we do about this and how do we fix it."
Again, sorry this is taking so long. I'm still working on it though.
The ACLs are being changed and should be serviced in February.
Will this also be fixed for unpackaged applications with <WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
?
Has this been serviced?
The ACLs are being changed and should be serviced in February.
Is this fixed? If so what needs to be updated on our ends?
Sorry for the late reply. This change was serviced on February 2nd.
To get the correct ACLs for Windows App SDK please either
- Remove then add Windows App SDK, or
- Update Windows App SDK to a newer version.
Essentially the framework package needs to be removed, then installed.
I'm currently looking into a way to verify the fix is on a system so I can let ya'll know if the patch is present.
@dhoehna Thanks for the reply! This will work for self-contained as well? Will we need to upgrade to 1.3 preview/wait for stable? or Will the WASDK's Feb release 1.2.4 suffice?
It is not fixed for self-contained apps as the original problem that RestartManager.exe
is not distributed still persists.
Still not fixed in 1.3.1
Any update on this? I'm able to restart the C++ packaged app, but I'm unable to restart the unpackaged application.
Is there any update on this issue? I have WindowsAppSDK 1.3.230724000 installed, and the problem is still there. My app is also an unpackaged application with WindowsAppSDKSelfContained
enabled. Thanks.
It takes over one year and this issue is still there. Is that reasonable for WinUI team?
The issue with RestartAgent.exe not being included in selfcontained apps is fixed in 1.4 preview 2.