Page 1 of 1

WP7 - Using the Microsoft AdControl Rate Topic: -----

#1 eclipsed4utoo   User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1536
  • View blog
  • Posts: 5,972
  • Joined: 21-March 08

Posted 16 November 2010 - 11:11 AM

For the Windows Phone 7 platform, Microsoft decided to roll-out it’s own mobile ad service. This service is Microsoft Advertising PubCenter. Along with the service, they also added a custom control that we developers can add to our Windows Phone 7 applications.

First, we will need to download the Advertising SDK. That can be done from here. After downloading, install it as you would any other .msi, but you will want to note the install directory. On Windows 7 64-bit, the install directory will be “C:\Program Files (x86)\Microsoft Advertising SDK for Windows Phone 7“.

So first, you will need to go to the PubCenter, create an account(which is free). Once your account is created, login, then go to the Setup tab. From here, you will want to register your mobile application and create an application ad unit. It may take some time for the Ad Unit or application to be approved, so we are allowed to use some testing values for development purposes.

Attached File  11-13-2010-10-10-17-AM.png (51.36K)
Number of downloads: 11

You will want to note the application ID and the Ad Unit ID. We will need both of these.

So let’s create a new WP7 project. I just created a simple project and named it AdControlDemo.

Once the project has been created, open the Toolbox. We are going to add a new tab for the AdControl. Right-click somewhere in the Toolbox, then choose Add Tab.

Attached File  11-14-2010-9-47-51-AM.png (15.87K)
Number of downloads: 9

I gave my tab the name Advertising Control.

Attached File  11-14-2010-9-46-38-AM.png (7.95K)
Number of downloads: 2

Now right-click in the new Tab area, and click Choose Items.

Attached File  11-14-2010-9-49-28-AM.png (16.86K)
Number of downloads: 2

When the Choose Items dialog comes up, click the Browse button.

Attached File  11-14-2010-9-50-48-AM.png (65.76K)
Number of downloads: 1

Navigate to the install directory of the Advertising SDK that was installed. You will want to add the Microsoft.Advertising.Mobile.UI.dll file.

Attached File  11-14-2010-9-52-34-AM.png (70.35K)
Number of downloads: 1

You will now see that the AdControl has been added to our list of items. Now click OK.

Attached File  11-14-2010-9-54-11-AM.png (62.65K)
Number of downloads: 1

Now the AdControl has been added to our Toolbox.

Attached File  11-14-2010-9-55-24-AM.png (8.35K)
Number of downloads: 1

Now we are going to simply drag the control onto our screen. Now open the Properties window, and you will see two properties for the AdUnitId and the ApplicationId. For testing purposes, you can use “test_client” as the ApplicationId and “TextAd” as the AdUnitId.

So let’s run our application in the emulator by hitting F5, and you will see test ads showing up.

Now, once you setup your own application and ad unit and replaced the test values with your values, you will need to add this code to one of the initialization methods in the App.cs. I put it at the bottom of the constructor.

Microsoft.Advertising.Mobile.UI.AdControl.TestMode = false;

Without this code, the control will not show on the screen.

You now have advertising in your WP7 application.

Is This A Good Question/Topic? 0
  • +

Page 1 of 1