Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- The group or resource is not in the correct state to perform the requested operation.
- private async Task<bool> SetLaunchOnLogin_UWP_Async(bool shouldLaunchOnLogin)
- {
- try
- {
- var startupTask = await StartupTask.GetAsync("MyProjectStartupId");
- switch (startupTask.State)
- {
- case StartupTaskState.Disabled:
- System.Diagnostics.Debug.WriteLine("Startup is disabled. Will ask");
- // The code reaches here, but always throws an exception when calling RequestEnableAsync():
- return (await startupTask.RequestEnableAsync()) == StartupTaskState.Enabled;
- case StartupTaskState.Enabled:
- System.Diagnostics.Debug.WriteLine("Startup is enabled. Will disable");
- startupTask.Disable();
- return false;
- default:
- return false;
- }
- }
- catch (Exception ex)
- {
- System.Diagnostics.Debug.WriteLine("SpecificPlatformFunctions_UWP - SetLaunchOnLogin_UWP_Async ERROR: " + ex.ToString());
- }
- return false;
- }
- Startup is disabled. Will ask
- Exception thrown: 'System.Exception' in System.Private.CoreLib.ni.dll
- SpecificPlatformFunctions_UWP - SetLaunchOnLogin_UWP_Async ERROR: System.Exception: The group or resource is not in the correct state to perform the requested operation. (Exception from HRESULT: 0x8007139F)
- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
- at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
- at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
- at MyProject.UWP.DependencyServices.SpecificPlatformFunctions_UWP.<SetLaunchOnLogin_UWP_Async>d__13.MoveNext()
Add Comment
Please, Sign In to add comment