Search code examples
windows-phone-7background-agent

BackgroundAgent trying to do updates to my AdControl?


I tried to run the Marketplace Test Kit and it failed at Capability Validation with a bunch of calls that Microsoft.Advertising.Mobile.dll was trying to make. This is understandable, but in no instance am I attempting to update the AdControl from the BackgroundAgent. The closest thing I can think of is in this:

 public ScheduledAgent()
    {
        if (!_classInitialized)
        {
            _classInitialized = true;
            // Subscribe to the managed exception handler
            Deployment.Current.Dispatcher.BeginInvoke(delegate
            {
                Application.Current.UnhandledException += ScheduledAgent_UnhandledException;
            });
        }
    }

Is the Application.Current call what is trying to engage the ad control? If so, how can I prevent it from doing so?

Edit: here is the output of one of the error messages:

 Unsupported API cannot be used by a background agent. Assembly Microsoft.Advertising.Mobile.dll was trying to use Microsoft.Phone.Tasks.PhoneCallTask::.ctor.

Solution

  • Okay, it wasn't related to the code sample at all. What was the issue is that I was generating my ad controls via a Windows Phone Library I created. This library's Models were being used by the background agent and this apparently made the test kit believe the application was using the Ad logic somehow.

    I removed the Ads.cs and migrated the things it was doing into the pages themselves and this resolved the issue.

    edit: I think it is safer to say that it wasn't the Marketplace Test Kit thinking that the background agent was using the AdControl's library, but rather it had the ability to do so. I figure that is worth distinguishing.