I'm having a persistent problem within my Windows 8 app.
I want to register a BackGroundTask like this:
private void CheckTaskRegistration()
{
foreach (var task in BackgroundTaskRegistration.AllTasks)
{
Debug.WriteLine(task);
if (task.Value.Name == "CheckConTask")
{
isTaskRegistered = true;
break;
}
}
if (isTaskRegistered)
{
Debug.WriteLine("debug1");
}
else if (!isTaskRegistered)
{
BackgroundTaskBuilder btb = new BackgroundTaskBuilder();
btb.Name = "CheckConTask";
btb.TaskEntryPoint = "Btasks.CheckConTask";
BackgroundTaskRegistration task = btb.Register();
Debug.WriteLine("debug2");
}
}
Everytime that I run the code on Local Machine it gives me the following error:
"Value does not fall within the expected range."
I've been searching on stackoverflow (Like here) and everywhere but I can't seem to find any solution...
It is also hard to find any information about this error since it is so generic..
I've created a whole new project with sample code like this and nothing.
Any suggestions what the problem might is?