locked
Error when calling RequestAccessAsync: "The request is not supported." RRS feed

  • Question

  • I have two problems.

    1) I get this error (from e) "{System.Exception: The request is not supported. at Windows.ApplicationModel.Background.BackgroundExecutionManager.RequestAccessAsync()" when I call RequestAccessAsync:

                BackgroundAccessStatus result = 0;
                await System.Threading.Tasks.Task.Delay(1000);
                try {
                result = await BackgroundExecutionManager.RequestAccessAsync();
                }
                catch (Exception e)
                {
                string sTT = "{0} Exception caught.";
                }
    
                if (result == BackgroundAccessStatus.AllowedMayUseActiveRealTimeConnectivity || result == BackgroundAccessStatus.AllowedWithAlwaysOnRealTimeConnectivity)
                    {
                    foreach (var task in BackgroundTaskRegistration.AllTasks)
                        {
                        if (task.Value.Name == TASK_NAME)
                            task.Value.Unregister(true);
                        }
    
                    BackgroundTaskBuilder builder = new BackgroundTaskBuilder();
                    builder.Name = TASK_NAME;
                    builder.TaskEntryPoint = TASK_ENTRY;
                    builder.SetTrigger(new TimeTrigger(15, false));
                    var registration = builder.Register();
                    }
    

    2) RequestAccessAsync is called everytime the main page is loaded. It doesn't matter whether I put it in "public MainPage()" or "protected async override void OnNavigatedTo(NavigationEventArgs e)". I'd like to have it only called at program start.

    Saturday, February 8, 2014 2:51 PM

All replies

  • For the first I'm not sure offhand, but check that you have appropriate extensions set in your manifest. See How to declare background tasks in the application manifest

    For the second you'd have to put this somewhere called once or check a global flag. If it's in the MainPage constructor then it should run every time the main page is constructed. Likewise in navigation events when navigating.

    That said, it shouldn't be a problem since I believe it will only offer the UI once and after that return silently.

    --Rob

    Saturday, February 8, 2014 3:47 PM
    Moderator
  • Only crashes when debugging in the Simulator, Local Machine it does not crash.
    Saturday, February 8, 2014 4:56 PM
  • Same here - not supported by the simulator, but fine with the local machine. 

    Hong

    Thursday, April 23, 2015 4:27 AM