Could anyone shed some light on what may cause System.Exception: 'Invalid window handle' thrown by CoreApplication.RequestRestartAsync("")?
Could anyone shed some light on what may cause System.Exception: 'Invalid window handle' thrown by CoreApplication.RequestRestartAsync("")?
I used it without problems, so I wonder if the problem is related to the moment you call it. In which state is the app when you call RequestRestartAsync? On the UI thread or on another thread? It is running on a desktop or on other device? Which TargetPlatformVersion and TargetPlatformMinVersion?
Thank you for looking into it. I should have posted the code snippet:
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
async () => {
try
{
AppRestartFailureReason arfr = await CoreApplication.RequestRestartAsync("");
if (arfr == AppRestartFailureReason.NotInForeground
|| arfr == AppRestartFailureReason.Other)
{
Utility.LogMessageJsonAsync("Restarting failed: " + arfr);
}
else
{
//do nothing
}
}
catch (Exception ex)
{
Utility.LogMessageJsonExAsynch("Exception from await CoreApplication.RequestRestartAsync():", ex);
}
});
It was running on a desktop. I also should have mentioned this happens only occasionally. The UWP app targets 18632.
Yep, I run above code within a blank uwp app, and it does not throw any exceptions, I could not reproduce your issue, could you mind share a demo that could reproduce this problem that will be better to find the reason.
14 people are following this question.
How to write and read multiple types of data using Data Writer and Data Reader
Consuming UWP mail api from WPF Desktop Bridge App
Get Network usage information in UWP apps
How to Get/Set Cookies in Windows.Web.Http API
Switch the ListView Datatemplate from one data template to another data template?