Errors With AdControl in Windows Phone 7.1 (Retail 7.5)

I recently implemented the AdControl in the trial version of an app I’ve got in the marketplace. It is remarkable how easy they’ve made it to add ads to your app, with the Microsoft Advertising ASK baked right into the Windows Phone 7.1 SDK.

Unfortunately, I couldn’t get the app displaying ads. I assumed there was something wrong with the way that I was implementing it, sent a couple emails out and went about finishing the other features I was working on. The error I was getting was:

A first chance exception of type ‘Microsoft.Advertising.Mobile.Shared.AdException’ occurred in Microsoft.Advertising.Mobile.dll

No detail, wrapping the control code I was using to add the control to the page with a try block produced no results, so I moved on.  Unfortunately, as the ad was not appearing, I forgot that I had stubbed it in and published the update to the marketplace.  Oops.

When I saw the update appear in the Marketplace, I installed the app and…there were the ads.  In the paid version.  Oops.

Check Your Manifest at the Door

Wait a minute! Everything I’ve read says that if you can’t see ads in the debugger that the ads won’t show up on the live app. So what gives?

In looking for help on the error, I hit the SDK documentation where I stumbled on the control’s events.aspx), where I found the ErrorOccurred event.  This little beauty solved all my problems.  Subscribing to this event – as easy as yourAdControl.ErrorOccurred += [tab] [tab] – and checking the properties on the exception provided the details on my problem: I was missing the ID_CAP_IDENTITY_USER declaration in my application manifest.

image

So Why Did It Work on the Live App?

Ah, right…when you submit your app to the Marketplace, Microsoft kindly builds your manifest for you with all the correct capabilities.  If you have extras, they take them out. If you don’t have the ones you need, they inject them.

So, when you accidently publish your app with the AdControl in it, but you’re missing the capabilities from your manifest, fear not! The App Hub publishing process will take care of everything. 

Just try to remember to avoid pushing out your app with ads in the paid version.

Going Forward

So, here’s some things you should do when using the AdControl:

  • Familiarize yourself with SDK if you’re wondering about monetizing your app.  It’s super simple.
  • Make sure you’re properly registered with Pub Center and follow the instructions they give.  It’s straightforward.
  • Add an event handler to the AdControl.ErrorOccured event. If you run into any issues with the control, it’ll set you straight.

 

Good luck!