How To Connect Window Phone 7 and Windows 8 app to Microsoft pubCenter
When writing a Windows Phone 7 or Windows 8 application you might want to put some Ads, some applications cost money when others has ads.
Microsoft pucCenter isn’t the only solution for Windows 7 and Windows 8 but it’s something easy and simple to do when working with Visual Studio to developer applications.
Microsoft Advertising pubCenter empowers Web site publishers and Windows Phone 7 application developers to place ads within web pages and Windows Phone 7 apps. When users click on these ads, the publisher earns money from the advertiser, via Microsoft.
Download Demo Project
Step 1: Create pubCenter account and register a new application
Enter https://pubcenter.microsoft.com/Login, register using Live Id or create new account.
Then navigate to “Setup” and choose applications, and click on “Register application”

In the application registration choose what type of application it will be, a Windows Phone 7 or Windows 8? and save your new application.

After the save completes copy and save your application id (we’ll use it later).

Step 2: Create Ad Units
After you registered your application you need to create a ad unit.
An ad unit defines the size and content of ads that appear on your site or in your application.
You can create more than one ad unit in order to show different ads in different pages or the same page in your application.

Choose the size and categories for that ad unit.

Again, copy and save the ad unit id (we’ll use it later).

Step 3: Create Winnows Phone 7 Application With Ads
First download the Microsoft Advertising SDK for Windows Phone or Download Win 8 Ad SDK
In Visual Studio 2010 create new project of type Windows Phone Application.

Add reference to “Microsoft.Advertising.Mobile.UI” located here "C:\Program Files (x86)\Microsoft SDKs\Advertising for Phone\Libraries\Microsoft.Advertising.Mobile.UI.dll"

Step 4: Place Ad Inside Your Page
Open “MainPage.xaml” and add the following instead of the the ContentPanel grid, notice the ApplicationId is the same for all three ads controls but the AdUnitId is different, this what cause the ads to show different ads.
* Leave fixed size : Width="480" Height="80" , this can cause the ad to disappear.
<Grid x:Name="ContentPanel" Grid.Row="1">
<StackPanel>
<my:AdControl Width="480" Height="80"
ApplicationId="4619ce4c-5ea4-46b9-8f36-f5ee1f4e1155"
AdUnitId="10029839" />
<my:AdControl Width="480" Height="80"
ApplicationId="4619ce4c-5ea4-46b9-8f36-f5ee1f4e1155"
AdUnitId="10020345" />
<my:AdControl Width="480" Height="80"
ApplicationId="4619ce4c-5ea4-46b9-8f36-f5ee1f4e1155"
AdUnitId="10016624" />
</StackPanel>
</Grid>
The Results:

Download Demo Project