Background task with entry point XX and name XX can not activate; error code: 0x80131509

0

I have an UWP app with a simple background task wich I want to be executed when the user starts session in Windows 10 (Anniversary Update).

I registered the task and can see it in powershell using "Get-AppBackgroundTask". The problem is the task is not executing when user starts session. Here is task registration code:

var status = await BackgroundExecutionManager.RequestAccessAsync();
bool accessgranted = status != BackgroundAccessStatus.DeniedByUser
        && status != BackgroundAccessStatus.DeniedBySystemPolicy
        && status != BackgroundAccessStatus.Unspecified;

if (accessgranted)
{
    await RegisterTask("MyBgTask", 
        typeof(BgStartTask).FullName, 
        new SystemTrigger(SystemTriggerType.SessionConnected, false));
}


private async Task<IBackgroundTaskRegistration> RegisterTask(string taskName, string entryPoint, IBackgroundTrigger trigger)
{
    var builder = new BackgroundTaskBuilder
        {
            Name = taskName,
            TaskEntryPoint = entryPoint,
            IsNetworkRequested = true
        };
    builder.SetTrigger(trigger);

    var taskRegistration = builder.Register();
    return taskRegistration;
}

Here is the complete check of actions made:

  • Added the refference of BgStartTask project to my uwp app.
  • Added entrypoint in apppackagemanifest.

When I start session I can see in event viewer the following error under "BackgroundTaskInfraestructure->Operational":

Background task with entrypoint StartTask.BgStartTask and name MyBgTask can not activate; error code: 0x80131509.

I've tried to re-register the task with no success. Also, if I execute the task from VS 2017 it works ok... Any ideas please?

c#
uwp
background-task
asked on Stack Overflow Dec 15, 2017 by Cabuxa.Mapache • edited Dec 15, 2017 by Cabuxa.Mapache

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0