Tuesday, October 4, 2011

Microsoft Advertising SDK

It goes without saying that everybody want to be rewarded for his job. As for me, I want to earn some money by showing advertisements in my game. I'm inspired to use this kind of monetization by this blogpost

Since I'm developing my game for WP7 on XNA I've decided to use Microsoft Advertising SDK for WP7. 

When I started to incorporate the Ads into my game I went crazy! It seemed to be very easy to do, because in the end it's just a block with a content. However it didn't work. The Ad simply didn't show up. 

In order to get a clue on what was happening, I subscribed to the ErrorOccurred event of DrawableAd. When I ran the app the event was fired and I could see that the error was:

"The remote server returned an error: NotFound."
OK. I found on the Internet some info that it could be because there are no ADs for my region right now(Nederland). I decided to simulate that I am somewhere in New York by setting coordinates of this city to the latitude & longitude properties of my banner. Fail again! 

I found a sample project here and it works just fine! My location didn't matter actually. I made sure that my code was exactly the same as in this sample project. After another hour I read on one forum that the error might be caused by the configuration settings in WMAppManifest.xml. I compared these two files in the projects and there was a difference. I didn't have a number of capability settings in my project:

      <Capability Name="ID_CAP_NETWORKING" />
      <Capability Name="ID_CAP_LOCATION" />
      <Capability Name="ID_CAP_SENSORS" />
      <Capability Name="ID_CAP_MICROPHONE" />
      <Capability Name="ID_CAP_PHONEDIALER" />
      <Capability Name="ID_CAP_PUSH_NOTIFICATION" />
      <Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />

After I added these settings, everything started to work as I wanted. Hope it will help.


  1. Yeah, VS will write these caps in when you start a new 7.1 app. But if you are adding Ads after you've built the app or are upgrading from 7.0, make sure those caps are there.

  2. Thanks! That's the reason. I've created my project in 7.0