locked
"Access is Denied" registering a background task?

    Question

  • Does anyone know why the below code would throw "Access is Denied" on the last step?   I have registered access to the lock screen. 

            var builder = new Windows.ApplicationModel.Background.BackgroundTaskBuilder();

            builder
    .name = "myBackgroundTask";
            builder
    .taskEntryPoint = "backgroundtask.js";
           
    var trigger = new Windows.ApplicationModel.Background.TimeTrigger(15, false);
            builder
    .setTrigger(trigger);

           
    //if (condition !== null) {
           
    //    builder.addCondition(condition);
           
    //}

           
    var task = builder.register();

    Thanks

    Josh

    Tuesday, March 6, 2012 4:09 PM

Answers

  • I figured it out.. It was a configuration issue.. I didn't notice when you setup the declearation in the manifest that there is a checkbox for "timer"
    Tuesday, March 6, 2012 8:00 PM

All replies

  • I figured it out.. It was a configuration issue.. I didn't notice when you setup the declearation in the manifest that there is a checkbox for "timer"
    Tuesday, March 6, 2012 8:00 PM
  • Hi,
    var builder=new BackgroundTaskBuilder();
    
    builder.Name=name;
    builder.TaskEntryPoint=taskEntryPoint;
    builder.SetTrigger(trigger);
    
    if(condition!=null)
      builder.AddCondition(condition);
    
    builder.Register(); // in this step I get exception System.UnauthorizedAccessException. Additional information: Access is denied.

    This exception is throwed in Windows 8 release preview. In consumer preview I did not get this exception.

    I use SystemTrigger (SystemtriggerType.UserPresent) and SystemCondition(SystemConditionType.InternetAvailable)

    In Package.appxmanifest file I set System event checkbox to true and input Entry point value. Also in Package.appxmanifest code I removed 'Executable' attribute.

    But when I set SystemTrigger (SystemTriggerType.InternetAvailable) and SystemCondition(SystemConditionType.UserPresent), then it is working.

    Could you please help me understand this behavior?

    Thank you in advance!

    Monday, June 4, 2012 2:51 PM
  • as you are using time trigger you should check the timer event in manifest file,be sure it is checked.
    Friday, December 7, 2012 1:07 PM