locked
How to add Advertising to an app developed through Windows Phone App Studio RRS feed

  • Question

  • I developed an app through 'windows phone app studio' and got .XAP file .Now i need to integrate advertising in it.How do i do that ? Should i need to install Visual Studio to integrate the 'add' ?
    Thursday, September 5, 2013 2:17 PM

Answers

  • 100% working Easy Steps.

    How do I enable ads on my app?

                 Ads enabled            

                    In order to enable advertisements in your Windows Phone application, you need to do the following:               

                
    • Install the tools - Install Visual Studio, and install the latest version of the Windows Phone SDK                
    • Obtain an AdUnitId and ApplicationId keys - Register your app at the Pubcenter site with your Microsoft Account, create a Windows Phone 8 app (ApplicationId), and create an AdUnitID                
    • Update the App Studio code                                  
      • Download the App Studio source code for the application by clicking “Download Source Code” after you’ve generated your app.                        
      • Open the XAML code and find the AdControl line in the file View/YourFirstPage.xaml. The code is commented, so if you want to use it, you need to uncomment it.                        
      • Replace the AdUnitID and ApplicationID in the code - In the AdControl XAML, there have two important properties: AdUnitId and ApplicationId. The current values of these two properties are intended for demo purposes only. Before publishing your App to the Windows Phone Store you need to replace these two values with the values you obtained through PubCenter.                         

        < ads grid.row="1" height="80" width="480" isautocollapseenabled="True" isautorefreshenabled="True"adunitid="Image480_80"applicationid="test_client" />                        

                    For more information about advanced options in the Pubcenter AdControl, please visit: Integrating the AdControl Using the Visual Designer.             

    Wednesday, November 20, 2013 12:21 AM

All replies

  • Yes, you will need to download the generated code that App Studio creates for you. Open up that solution in Visual Studio then you will be able to customize the app further via code.

    Regards, Kyle Reddoch

    • Proposed as answer by Kyle Reddoch Friday, September 6, 2013 7:16 PM
    • Marked as answer by Santhi Sagar1 Saturday, September 14, 2013 9:03 AM
    • Unmarked as answer by Santhi Sagar1 Saturday, September 14, 2013 9:08 AM
    • Unproposed as answer by Santhi Sagar1 Monday, September 23, 2013 1:40 PM
    Friday, September 6, 2013 7:15 PM
  • hi:

    It´s posible to downgrade os versión to 7 from visual studio?

    THX

    Friday, September 6, 2013 11:34 PM
  • I do not think it is possible to do that but I have not tried it.

    Regards, Kyle Reddoch

    Saturday, September 7, 2013 2:44 AM
  • Hello smartzuup,

    Downgrading the OS version to 7 is possible, you can re-use 90% of the source code of your application windows phone. Here we explain the steps that you have to follow.

    1. Create a Windows Phone 7 empty project named WP7App
    2. Add a Windows Phone Class Library Project named Entities
    3. Add a Windows Phone Class Library Project named Repositories
    4. Open the solution of your application created with Windows Phone App Studio
    5. Copy the contents of the three projects of the Windows Phone 8 solution in the three projects of the windows phone 7 solution.
    6. Add reference of the Entities and Repositories Projects to WP7App project.
    7. You’ll have to rewrite some services, for example Tiles.
    8.  You’ll have to rewrite 10% of the code in all views. Here you might use the Windows Phone Silverlight Toolkit for the controls that don’t support Windows Phone 7.

    Thank you for using Windows Phone App Studio

    Wednesday, September 11, 2013 7:35 AM
    Moderator
  • Design view is missing in Visual Studio so I opted for integrating the add through code (http://msdn.microsoft.com/en-US/library/advertising-mobile-windows-phone-8-adcontrol-walkthrough-api%28v=msads.20%29.aspx) but I got struck here.....

    Grid grid = (Grid)this.LayoutRoot.Children[1];
    grid.Children.Add(adControl);

    Saturday, September 14, 2013 9:08 AM
  • same here, stuck on Grid.

    Error 2 The type or namespace name 'Grid' could not be found (are you missing a using directive or an assembly reference?) C:\Users\sbucci\Downloads\app\src\WP8App\App.xaml.cs 49 13 WP8App
    Error 3 The type or namespace name 'Grid' could not be found (are you missing a using directive or an assembly reference?) C:\Users\sbucci\Downloads\app\src\WP8App\App.xaml.cs 49 26 WP8App
    Error 4 'WPAppStudio.App' does not contain a definition for 'LayoutRoot' and no extension method 'LayoutRoot' accepting a first argument of type 'WPAppStudio.App' could be found (are you missing a using directive or an assembly reference?) C:\Users\sbucci\Downloads\app\src\WP8App\App.xaml.cs 49 36 WP8App


    Steve Bucci


    Thursday, September 19, 2013 8:06 PM
  • I'm a absolute beginner could you explain the above clearly ? 
    Monday, September 23, 2013 1:38 PM
  • Hello Steve Bucci,

    Can you give us a screenshot of the wrong file so we can see the code and to study where the bug could be?

    Thank you.


    Wednesday, September 25, 2013 2:19 PM
    Moderator
  • I've added a OneNote with my repro steps here: http://sdrv.ms/GzXURx

    Steve Bucci Microsoft

    Wednesday, October 2, 2013 6:57 PM
  • Why don't you use the designer mode?

    http://msdn.microsoft.com/en-US/library/advertising-mobile-windows-phone-8-adcontrol-visual-designer(v=msads.20).aspx

    It's much easier to implement and change in the app.



    Siempie76


    • Edited by siempie76 Thursday, October 3, 2013 12:18 PM
    Thursday, October 3, 2013 9:36 AM
  • Hello,

    Apparently the code sample in step 21 of your OneNote document is placed in the wrong file (App.xaml.cs). It should be in the file MainPage.xaml.cs. The MainPage is the first page of an App Studio application.

    Try to put the following in the end of the constructor:

         LayoutRoot.Children.Add(adControl);
         Grid.SetRow(adControl, 1);

    Instead of:

        Grid grid = (Grid)this.LayoutRoot.Children[1];
        grid.Children.Add(adControl);

    And if you want add adverting in this page you will need add the following code in your MainPage.xaml:

         <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="80"/>
         </Grid.RowDefinitions>

    The second row is where the advertising should go.

    Thank you for using Windows Phone App Studio.

    Thursday, October 3, 2013 3:01 PM
    Moderator
  • App Studio does not output a MainPage.xaml.

    I have tried Designer mode and the ad does not show, again this may be because there is no mainpage.xaml.


    Steve Bucci Microsoft

    Thursday, October 3, 2013 7:20 PM
  • Hello,

    The name of the MainPage.xaml of an App Studio application isn’t MainPage, it’s the name of the page of the first section of the application that you have created.

    The format is the following: NameFirstPage_SectionType.xaml

     I Hope this helps you.

    Friday, October 4, 2013 1:01 PM
    Moderator
  • Thanks!  Knowing the right place to put the code made a difference.

    It didn't like this code, however:
    <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="80"/>
         </Grid.RowDefinitions>

    Is it supposed to between <>?  VS didn't like it with or without the <> </> .  Should it be on that same page?

    I had better luck with Design view now that I know where to put everything, but I'd still like to know the answer for the best way to position the ad when not in Design view.


    Steve Bucci Microsoft

    Friday, October 4, 2013 3:34 PM
  • Hello,
     
    That code is for the definition of the rows of your page, and the advertising should be on that same page but not included in RowDefinitions. The position of the ad depends on you, but normally is on the bottom of the page.
     
    Thank you for using Windows Phone App Studio.
    Tuesday, October 8, 2013 4:41 PM
    Moderator
  • Please find the screenshot, So far Getting this error Atlast when trying to insert advertisements into an app developed through app studio and modification done following this forum best answers.

    • Proposed as answer by yoursloving Wednesday, November 20, 2013 12:19 AM
    • Unproposed as answer by yoursloving Wednesday, November 20, 2013 12:19 AM
    Monday, November 18, 2013 11:26 AM
  • 100% working Easy Steps.

    How do I enable ads on my app?

                 Ads enabled            

                    In order to enable advertisements in your Windows Phone application, you need to do the following:               

                
    • Install the tools - Install Visual Studio, and install the latest version of the Windows Phone SDK                
    • Obtain an AdUnitId and ApplicationId keys - Register your app at the Pubcenter site with your Microsoft Account, create a Windows Phone 8 app (ApplicationId), and create an AdUnitID                
    • Update the App Studio code                                  
      • Download the App Studio source code for the application by clicking “Download Source Code” after you’ve generated your app.                        
      • Open the XAML code and find the AdControl line in the file View/YourFirstPage.xaml. The code is commented, so if you want to use it, you need to uncomment it.                        
      • Replace the AdUnitID and ApplicationID in the code - In the AdControl XAML, there have two important properties: AdUnitId and ApplicationId. The current values of these two properties are intended for demo purposes only. Before publishing your App to the Windows Phone Store you need to replace these two values with the values you obtained through PubCenter.                         

        < ads grid.row="1" height="80" width="480" isautocollapseenabled="True" isautorefreshenabled="True"adunitid="Image480_80"applicationid="test_client" />                        

                    For more information about advanced options in the Pubcenter AdControl, please visit: Integrating the AdControl Using the Visual Designer.             

    Wednesday, November 20, 2013 12:21 AM
  • With the latest update on App Studio we just have to remove some commented code on the app and rebuild it on Visual Studio.

    I'm sure a simple option to enable/disable ads and insert the pubCenter Application ID and Ad units is easy to implement on App Studio so that the generated app can be ad enabled, instead of having to go to Visual Studio.

    Thanks!

    Vote here: http://wpdev.uservoice.com/forums/216486-windows-phone-app-studio/suggestions/4257668-add-ad-control-integrated-directly-into-wp-app-stu


    i9Ware apps | http://www.windowsphone.com/en-US/store/publishers?publisherId=i9Ware

    Wednesday, December 11, 2013 8:03 PM
  • I'm having some issues after removing the commented section and adding my AdUnitID and ApplicationID to the code, i'm unable to buid the app because of the error:

    Error    1    Cannot resolve dependency to assembly 'Microsoft.Advertising.Mobile, Version=6.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.    (...)\WP8App\View\MenuSection_SystemMenu.xaml    1    1    WP8App

    Some more errors:

    Error    1    Cannot clear the icon while in a list
    Parameter name: value    (...)\WP8App\View\MenuSection_SystemMenu.xaml    44    4    WP8App
    Error    2    Could not load type 'Microsoft.Advertising.RendererOptions' from assembly 'Microsoft.Advertising.Mobile, Version=6.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.    (...)\WP8App\View\MenuSection_SystemMenu.xaml    124    9    WP8App
    Error    3    Undefined CLR namespace. The 'clr-namespace' URI refers to a namespace 'WPAppStudio.Controls.Maps' that could not be found.    (...)\WP8App\View\MenuSection_SystemMenu.xaml    10    16    WP8App
    Error    4    Cannot resolve dependency to assembly 'Microsoft.Advertising.Mobile, Version=6.2.960.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.    (...)\WP8App\View\MenuSection_SystemMenu.xaml    1    1    WP8App

    If i left the code commented the build works fine! I have another similar app made on App Studio and don't have any issues with it.

    I also believe it gets worse if i update the Nuget packages...

    Can someone help?

    Thanks!


    i9Ware apps | http://www.windowsphone.com/en-US/store/publishers?publisherId=i9Ware


    • Edited by i9ware Monday, December 16, 2013 5:46 AM
    Monday, December 16, 2013 5:28 AM
  • Hello i9ware,

    Thank you for your feedback. This is a known bug that will be fixed as soon as possible.

    Meanwhile, you can follow these steps to resolve the problem.

       1. Open the References folder of the WP8App project
       2. Delete the Microsoft.Advertising.Mobile.UI reference
       3. Access the properties of the Microsoft.Advertising.Mobile reference and copy the path
       4. Find and add the Microsoft.Advertising.Mobile.UI reference in the path you just copied
       5. To do Rebuild of the entire solution

    Thank you for using Windows Phone App Studio.



    Monday, December 16, 2013 5:10 PM
    Moderator
  • Hi!

    Thanks for the help, it worked!!

    Do you mind answering other question: when i go to "Manage Nuget Packages" i have some updates for the packages of the app, should i update them or not?

    Thanks again!


    i9Ware apps | http://www.windowsphone.com/en-US/store/publishers?publisherId=i9Ware

    Monday, December 16, 2013 6:24 PM
  • Hello Anonymous,

    You said "Meanwhile, you can follow these steps to resolve the problem" etc.

    I obviously have the same problem since I've come to this thread.

    I tried this (with the test values - Image480_80 and test_client for ad id and app id) and I also get errors. Strangely it builds successfully, although when I look in the Error List there are 4 or 5 errors, mostly saying "cannot clear icon when in a list", but culminating in this -

    "Error 5 Could not load type 'Microsoft.Advertising.RendererOptions' from assembly 'Microsoft.Advertising.Mobile, Version=6.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. C:\FromBrick\Projects\WinPhone8\Market Links\src\WP8App\View\MenuSection_Top7.xaml 105 5 WP8App"

    And I see a red X plus the text "Cannot create an instance of AdControl" where the ad should be. Nevertheless the app runs and I see the MS test ad.

    The MS Mobile Ad DLLs date from 27/11/2013 and are both at version 6.2.960.0

    If I want to modify the XAML for the start page and see real errors I still need to comment out the ad control. I am also curious if ads will actually be shown now. I have several App Studio apps out in the wild with ads but have never had an ad request made or shown according to my PubCenter reports.

    Is It time to update my old apps with the new DLLs or should I wait for fixes?

    Friday, December 20, 2013 9:46 AM
  • Check the previous answer given by the Moderator, it worked for me:

    Meanwhile, you can follow these steps to resolve the problem.

       1. Open the References folder of the WP8App project
       2. Delete the Microsoft.Advertising.Mobile.UI reference
       3. Access the properties of the Microsoft.Advertising.Mobile reference and copy the path
       4. Find and add the Microsoft.Advertising.Mobile.UI reference in the path you just copied
       5. To do Rebuild of the entire solution

    Thank you for using Windows Phone App Studio.

    If you have your errors again after fixing the Microsoft.Advertising.Mobile.UI reference, rebuild the app twice, and the second time will be ok.


    i9Ware apps | http://www.windowsphone.com/en-US/store/publishers?publisherId=i9Ware

    Friday, December 20, 2013 5:50 PM
  • is it possible to do so in windows 7?
    Tuesday, February 11, 2014 10:55 AM
  • I'm interested in this question as well.

    Rod

    Tuesday, January 20, 2015 10:05 PM
  • This is still an issue even in VS 2013 and 8.1 Silverlight. The easiest way I found to fix is to remove the auto referenced Microsoft.Advertising.Mobile and Microsoft.Advertising.Mobile.UI and re-reference them through Add References -> Extensions
    Thursday, June 11, 2015 1:27 AM
  • This did not work for me.  I still have the "cannot resolve dependency to assembly" error.  I am using Windows Phone 8.1 with a XAML front-end.  Could that be the problem?
    Thursday, April 14, 2016 2:54 AM
  • Hi,

    Is this related a Windows App Studio generated application? If so, have you tried to re-generate your project? If it still have an error, please, can you send your AppId to appstudiosupport@outlool.com? If it is not a Windows App Studio generated app, I would suggest you to post your question in a more general Windows Phone forum.

    Thanks.

    Friday, April 15, 2016 11:26 AM
    Moderator