2 Comments

I’ve been working with an app which has both the Windows Phone 7.5 and the Windows Phone 8 versions. Both of these versions have their own project files which target the correct platform but they reference and use a background agent compiled as a 7.5 project. The problem: Background agent was working on the 8.0 version, but the 7.5 threw a System.InvalidOperationException when it tried to start the agent. Here’s the stack trace:

And here’s the agent:

image

The application correctly referenced the project and the WMAppManifest.xml contained the agent:

      <ExtendedTask Name="BackgroundTask">
        <BackgroundServiceAgent Specifier="ScheduledTaskAgent" Name="scheduled-agent-wp7" Source="scheduled-agent-wp7" Type="scheduled-agent-wp7.ScheduledAgent" />
      </ExtendedTask>

So what was the problem? The XML.

When you add a reference to the agent, it automatically creates the XML into the WMAppManifest.xml. But in this case, it generated the wrong XML.If you check screenshot of the code, you can see that the agent’s class is scheduled_agent_wp7.ScheduledAgent. But the generated XML tries to reference a class scheduled-agent-wp7.ScheduledAgent.

Manually fixing the WMAppManifest.xml helped to solve the issue.

Comments

Comment by Windows Store Developer Links &#8211; 2013-01-22 | Dan Rigby

[...] Windows Phone 7 (Toni Petrina)Copying Nokia’s Photobeamer with SignalR and WP8 (Nico Vermeir)Windows Phone Background agent – Solving the InvalidOperationException (Mikael Koskinen)Silverlight Show Webinar on the New Features in the WP8 SDK Part 2 (Michael [...]

Comment by air max 90

air max 90...

Once again another great entry. I actually have a few things to ask you, would be have some time to answer them?...