daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest May 17th, 2018 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. The group or resource is not in the correct state to perform the requested operation.
  2.    
  3. private async Task<bool> SetLaunchOnLogin_UWP_Async(bool shouldLaunchOnLogin)
  4. {
  5.     try
  6.     {
  7.         var startupTask = await StartupTask.GetAsync("MyProjectStartupId");
  8.  
  9.         switch (startupTask.State)
  10.         {
  11.             case StartupTaskState.Disabled:
  12.  
  13.                 System.Diagnostics.Debug.WriteLine("Startup is disabled. Will ask");
  14.                 // The code reaches here, but always throws an exception when calling RequestEnableAsync():
  15.                 return (await startupTask.RequestEnableAsync()) == StartupTaskState.Enabled;
  16.  
  17.             case StartupTaskState.Enabled:
  18.  
  19.                 System.Diagnostics.Debug.WriteLine("Startup is enabled. Will disable");
  20.                 startupTask.Disable();
  21.                 return false;
  22.  
  23.             default:
  24.                 return false;
  25.         }
  26.     }
  27.     catch (Exception ex)
  28.     {
  29.         System.Diagnostics.Debug.WriteLine("SpecificPlatformFunctions_UWP - SetLaunchOnLogin_UWP_Async ERROR: " + ex.ToString());
  30.     }
  31.  
  32.     return false;
  33. }
  34.    
  35. Startup is disabled. Will ask
  36. Exception thrown: 'System.Exception' in System.Private.CoreLib.ni.dll
  37. 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)
  38.    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
  39.    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  40.    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
  41.    at MyProject.UWP.DependencyServices.SpecificPlatformFunctions_UWP.<SetLaunchOnLogin_UWP_Async>d__13.MoveNext()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top