Adding Microsoft pubcenter ads in Windows Phone 8 apps

Recently lots of developers are seen facing problems with pubcenter ads. The impressions are at an all-time low still for some developers ads never show up (not even the test ads). There’s a little thing that developers should be mindful of and pubcenter will again start working for them. Heres a tutorial explaining how you could integrate pubcenter advertisements in your Windows Phone 8 apps.

Step 1. Visit pubcenter website and add a new application in it

Visit pubcenter website to create a new application and its ad unit



Note down the application ID and the ad unit ID which you just created.

Step 2. Add a reference to Microsoft.Advertising.Mobile.UI

Right click on the name of the project in solution explorer and choose Add>Reference. From the dialog box that appears choose Microsoft.Advertising.Mobile.UI and Microsoft.Advertising.Mobile and add it to your project. These references will enable you to use Microsoft’s pubcenter ads in your app. Instead of adding the reference you could have dragged and dropped the AdControl from Toolbox.



Step 3. Crucial step- Add the following capabilities carefully

Not adding all the required capabilities is main reason behind ads not showing up from pubcenter. Not choosing the right capabilities doesn’t lead to a syntax error and no error is reported while deploying the app. The following ID_CAP capabilities must be included in the manifest of the advertising-enabled app.


Go to Solution Explorer> Properties> WMAPPManifest.xml and move over to capabilities tab. From there choose the following capabilities. You may require other capabilities based on the type of application you are building but these will be required for pubcenter.


Step 4. Add a reference to the page where you want to display ads

Add the following reference to the page where you wish to display ads from pubcenter.



Step 5. Add the AdControl to your page

Add the AdControl to your page and insert the app id and ad unit id in it. If you are unsure where to put the code then have a look at the screen shot below. Also notice that the app id and ad unit id are set to test_client and Image480_80 respectively which is the default value. Also we have added an error occurred event handler.

Note: While debugging the app on emulator ads won’t show up if you are using a real app id and ad unit id. Instead if you use test values then a default ad will be visible    

Step 6. Add the error occurred event handler in code behind

You could use this event handler while debugging to know the reason for ads not appearing in the app. Most of the times if the ad control is correctly configured the reason for ads not appearing is low fill rates. Also you could use this event handler to load ads from another provider if ads from pubcenter fails. The code snippet show how you could add Google Admob’s ads when pubcenter fails to get an ad.

Here’s an article explaining how you could add Google AdMob in your Windows Phone 8 app.



A few users have claimed that they can’t find this event trigger in their ad control. They might not be using the latest Ad SDK.

When you run the app in the emulator ads should now appear. Here’s a screenshot of the sample app i built.



Get the full source code of the app here,

Download full project source code

Vivek Maskara

I am pursuing BTech in Software Engineering from Delhi Technological University. I develop apps, create websites and blog about my app experiences.

  • pythonflash

    Hi Vivek,

    I added the AdControl to the xaml and that seems fine.

    But when I added the AdControl_ErrorOccurred handler, Visual Studio Express complained that it couldn’t resolve AdView (Error 12 The type or namespace name ‘AdView’ could not be found (are you missing a using directive or an assembly reference?) )

    Are there any includes I need for that? It doesn’t suggest any when I click on the hint arrow under the squigly line.
    Thanks for this article, regardless.

    • pythonflash

      Oops, I think I found the answer. I neglected to click on your link to your other article on how to install adMob 🙂

  • pythonflash

    One more thing, than I’ll go away: You might have forgotten to mention where you declared your AppSettings variable, that you are using in the error handler for pubcenter error.

    • You could replace that just with the Admob adunit id. In my app i had the ad unit stored in a variable of another class so i used that instead.

  • pythonflash

    Vivek, thanks for your code. I actually implemented it.

    Not sure if you, yourself, have a Trial app, but had a question. When the user buys your App, I’m sure you’d want to hide the ad conditionally by checking the IsTrial boolean.

    Would you set the AdControl simply to Visibility.Collapsed? I’m wondering if doing this would get the desired result of not only, no longer showing either MS or Google ads, but also preventing either company from getting impressions from your page (you don’t want to break their rules).

    Or do you simply set the stackpanel ( or grid, etc..) that surrounds your AdControl, to Visibility.Collapsed ?

  • Pingback: [Windows Phone] Usando el nuevo control Ad Mediator | Javier Suárez | Blog()

  • Roberto Poggi

    hello, i’m download your example. If i launch project receive
    An unexpected error occurred during call to the ad source (Name: CNTX).

    • What version of Microsoft Advertising SDK are you using? Get the latest version..

  • Pingback: Using Ad Mediation in Windows Phone 8 app | ET Cheah()

  • Pingback: Microsoft App Submission Dashboard page sets AdUnitId to “none”? - DexPage()

  • Ravi Kumar

    I am adding it in my wp 8.1 project. I am getting error: Error 3 Unknown type ‘AdControl’ in XML namespace ‘clr-namespace:Microsoft.Advertising.Mobile.UI;assembly=Microsoft.Advertising.Mobile.UI’
    Help me to sort it out.

Read more:
How to create your first Windows Phone app
How to change the App name and Tile name of your Windows phone app
Data binding in Windows Phone app – One way binding