Over a million developers have joined DZone.

Make Money During your WP7 App's Free Trial

DZone's Guide to

Make Money During your WP7 App's Free Trial

· Mobile Zone ·
Free Resource
With the big news about the Windows Store yesterday and the new flexible app trials it will bring (time OR feature-based trials), DZone thought it would be good to share a tutorial about how to create a free trial and also make money with ads during the free trial.

It provides attractive option when the user can download and try your application before he/she can purchase your app. But just because you provide a free trial application doesn't mean you can’t make money doing so. You can display a Microsoft ad when the application is deployed as trial app and make money off of advertising! Today we will be building demo as shown below that displays the ad.


Preparing your Microsoft Ad control SDK

You can go to http://advertising.microsoft.com/mobile-apps and download the Ad SDK and sign up for Microsoft advertising.

Preparing advertising you want to display in Windows Phone apps

Once you are registered at Microsoft advertising and have installed the Microsoft Ad SDK on your machine you will need to login to https://pubcenter.microsoft.com/ and create “apps” that will give you Application ID as show in figure below.


Then you would need to create Ad units which will give you an Ad Unit ID as show in below figure.


Create Windows Phone with Microsoft Ad SDK in Trial Mode

Add Microsoft Ad SDK assembly

Once you created a Windows Phone project you would need to add a reference to Microsoft.Advertising.Mobile.UI.dll found in C:\Program Files (x86)\Microsoft Advertising SDK for Windows Phone 7 (64 bit) or C:\Program Files\Microsoft Advertising SDK for Windows Phone 7 (32 bit) as show in the figure below.


Add Ad Control to XAML

In XAML, you need to add two things to the xml namespace and the ad control as shown below.









   mc:Ignorable=”d” d:DesignWidth=”480″ d:DesignHeight=”768″

   FontFamily=”{StaticResource PhoneFontFamilyNormal}”

   FontSize=”{StaticResource PhoneFontSizeNormal}”

   Foreground=”{StaticResource PhoneForegroundBrush}”

   SupportedOrientations=”Portrait” Orientation=”Portrait” 



    <Grid x:Name=”LayoutRoot” Background=”Transparent”>


        <my:AdControl Height=”80″ HorizontalAlignment=”Left” Margin=”0,688,0,0″ x:Name=”ad” VerticalAlignment=”Top” Width=”480″/>



Add Code to Codebehind

Then in code behind you need to properly display ad control when your app is in trial mode. In the Microsoft.Phone.Marketplace namespace you will find the LicenseInformation class that contains the IsTrial() method that returns 'true' if the current app is in trial mode. If the app is in trial mode simply collapse the control. BY DEFAULT IsTrial() method ALWAYS RETURNS FALSE.

By default your AdControl will be in test mode and before shipping out your application you want to make sure to test AdControl in test mode by setting the AdControl.TestMode to false. Also you would want to set ApplicationId and AdUnitId properties using the values obtained in Microsoft ad center in the above steps. See below for the code that shows these explanations.

using Microsoft.Phone.Controls;

using Microsoft.Advertising.Mobile.UI;

using Microsoft.Phone.Marketplace;


namespace HowToCreateTrialAppWithAdSdk


    public partial class MainPage : PhoneApplicationPage


        public MainPage()




            // Ad if trial

            AdControl.TestMode = false;

            ad.ApplicationId = “your app id”;

            ad.AdUnitId = “your ad unit id”;

            ad.Visibility = System.Windows.Visibility.Collapsed;

            if (new LicenseInformation().IsTrial())


                ad.Visibility = System.Windows.Visibility.Visible;






Download Code


In this demo you learn about how to allow the user to install you app in trial mode and still make money using a Microsoft Ad.

Source: http://blog.toetapz.com/2010/11/03/how-to-create-trial-mode-application-with-microsoft-ad-support/


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}