Maybe this is a problem that I’m all alone on, but it took me some time to figure out.

I started up a ScheduledAgent for Windows Phone so that I could do some updates with a PeriodicTask, but when I ran the app, I was getting:

FileNotFoundException was unhandled – An unhandled exception of type ‘System.UI.FileNotFoundException’ occurred in System.Windows.ni.dll

Here’s what happened:

I had initially named my ScheduledTask project something stupid, so I needed to re-name it. I did so by clicking on the project name and renaming it.

image

If I had opened the properties section of the project

image

I would have seen that my assembly name (which names the actual file we’re looking for) was still the old stupid name

image

Once I update this name, I need to go to my WMAppManifest.xml file in my startup project and open it with the text editor.

<ExtendedTask Name="BackgroundTask">
  <BackgroundServiceAgent
    Specifier="ScheduledTaskAgent"
    Name="MyAwesomeTask"
    Source="MyScheduledTask"
    Type="MyScheduledTask.ScheduledAgent" />
</ExtendedTask>

It took me some time to figure out what the parameters in the BackgroundServiceAgent meant so:

Specifier – ScheduledTaskAgent

Name – the string name you give your task when you start it. In the example below, it would be Name=MyAwesomeTask:

PeriodicTask myPeriodicTask = new PeriodicTask("MyAwesomeTask");
ScheduledActionService.Add(myPeriodicTask);

Source – the name of the DLL that holds your task code. This is determined in the Assembly name box you see in the properties section of your csproj.

Type – the namespace.type notation that points to the actual object (which must inherit from ScheduledTaskAgent)