The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
Advertising example for SDK 7.11 RRS feed

  • Question

  • Hi all.

    Im trying to add Advertising in my app using SDK 7.11 but cant seem to find any examples of how this is done. All the examples I can find is for older SDKs.

    Does anyone have a link to an example of addind adds in a XNA application ?

    Thanks in advance

    Wednesday, April 18, 2012 10:36 PM

All replies

  • Hi,

    Are you using the following which is the latest version (6.1.320 published 3/27/2012) for the Windows Phone?
    http://www.microsoft.com/download/en/details.aspx?id=8729

    Integrate an Ad into a Windows Phone XNA Game
    http://msdn.microsoft.com/en-us/library/advertising-mobile-windows-phone-7-xna-api(v=msads.20).aspx

    -Mark
    Thursday, April 19, 2012 2:44 PM
  • Hi Mark

    Thanks for the reply.

    I have tried following your links/example, I can run the code but no advertising banner is displayed. Only the default blue screen.

    The Microsoft.Advertising.Mobile.Xna reference say:
    Runtime version : v2.0.50727
    Version : 6.1.0.0
    Windows Phone OS : Windows Phone OS 7.1

    Here is the complete code example:

    using

     

     

    System;

     

     

    using

     

     

    System.Collections.Generic;

     

     

    using

     

     

    System.Linq;

     

     

    using

     

     

    Microsoft.Xna.Framework;

     

     

    using

     

     

    Microsoft.Xna.Framework.Audio;

     

     

    using

     

     

    Microsoft.Xna.Framework.Content;

     

     

    using

     

     

    Microsoft.Xna.Framework.GamerServices;

     

     

    using

     

     

    Microsoft.Xna.Framework.Graphics;

     

     

    using

     

     

    Microsoft.Xna.Framework.Input;

     

     

    using

     

     

    Microsoft.Xna.Framework.Input.Touch;

     

     

    using

     

     

    Microsoft.Xna.Framework.Media;

     

     

    using

     

     

    Microsoft.Advertising.Mobile.Xna;

     

     

    namespace

     

     

    WP7_Ads

     

    {

     

     

     

    public class Game1 : Microsoft.Xna.Framework.Game

     

     

    {

     

     

    GraphicsDeviceManager graphics;

     

     

     

     

    SpriteBatch spriteBatch;

     

     

     

     

    DrawableAd bannerAd;

     

     

     

     


    public
    Game1()

     

    {

    graphics =

     

     

    new GraphicsDeviceManager(this);

     

    Content.RootDirectory =

     

     

    "Content";

     

    TargetElapsedTime =

     

     

    TimeSpan.FromTicks(333333);

     

    }

     

     

     


    protected
    override void Initialize()

     

    {

     

     

     

    AdGameComponent.Initialize(this, "test_client");

     

    Components.Add(

     

     

    AdGameComponent.Current);

     

    CreateAd();

     

     

     

    base.Initialize();

     

    }

     

     

     


    protected
    override void LoadContent()

     

    {

    spriteBatch =

     

     

    new SpriteBatch(GraphicsDevice);

     

    }

     

     

     


    protected
    override void UnloadContent()

     

    {

    }

     

     

     


    protected
    override void Update(GameTime gameTime)

     

    {

     

     

     

    if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)

     

     

     

     

    this.Exit();

     

     

     

     

    base.Update(gameTime);

     

    }

     

     

     


    protected
    override void Draw(GameTime gameTime)

     

    {

    GraphicsDevice.Clear(

     

     

    Color.CornflowerBlue);

     

     

     

     

    base.Draw(gameTime);

     

    }

     

     

     


    private
    void CreateAd()

     

    {

     

     

     

    int width = 480;

     

     

     

     

    int height = 80;

     

     

     

     

    int x = (GraphicsDevice.Viewport.Bounds.Width - width) / 2;

     

     

     

     

    int y = 5;

     

     

     

     

    string image = "Image480_80";

     

    bannerAd =

     

     

    AdGameComponent.Current.CreateAd(image, new Rectangle(x, y, width, height), true);

     

    }

    }

    }

     

    Thursday, April 19, 2012 11:57 PM
  • Your code appears very similar to the tutorial here.

    I recommend that you get the tutorial working first, then start making your customized changes incrementally in order to identify what step cause the ad to not work.

    You may need to call GraphicsDevice.Present() to actually show the content on the screen.

    Hope this helps,
    Mark
    Friday, April 20, 2012 5:05 PM
  • Hi Mark

    Thanks for helping. I have tried the tutorial you provide, and following it I still dont see any ads. 
    Can you confirm that turorial works with the new SDK ? 

    I have no errors or anything when I follow the tutorial. But dont see the ads.

    Can you contact me on bjoern_mikkelsen @ hotmail.com (mail or Messenger) ?

    Thanks for the help. 
    Friday, April 20, 2012 6:01 PM
  • Hi Bjoern,

    I am on vacation until the end of next week.  I will notify a team mate that you need help. In the mean time:

    1. Check the Known Issues of the Ad SDK, which has a few issues listed at "No Ads". For example note that using keywords limits availability of displayed ads.
    2. Ask for help at the Microsoft pubCenter for Mobile. Try a search for "no ads".

    Best Regards
    Mark
    Saturday, April 21, 2012 11:22 AM
  • I have tried the tutorial you provide, and following it I still dont see any ads. 
    Can you confirm that turorial works with the new SDK ?


    Mark asked me to follow up on this...

    I tried following the tutorial steps ...
    The first time I ran the app, in the 512 Mb emulator, I did not see the ad control.
    Next I tried running the app on a device where it worked correctly.

    It may be an emulator specific issue; however, when I now try to run the app in the emulator again it no longer reproduces the problem.

    FWIW: I tested using the latest libraries, from Ad SDK version 6.1.320.0.
    Monday, April 23, 2012 8:13 PM
  • Hi Eric

    Thanks for trying it out. And glad you also got to see the issue.

    I have tried to reinstall everything on a free pc but the issue is still the same.

    Installed :
    1. Visual Studio 2010
    2. Visual Studio 2010 SP1
    3. WPSDK 7.1
    4. WPSDK 7.1.1
    5. WPAdSDK 6.1.320.0 (http://www.microsoft.com/download/en/confirmation.aspx?id=8729)
    6. Followed the example mentioned earlier.

    Still the sam result, both on the emulator and two physical devices. (Samsung Omnia 7 & Nokia 800)

    One thing, when I look in Visual Studio and want to add the Microsoft.Advertising.Mobile.Xna reference it say it has :
    Version : 6.1.0.0 (shouldnt this be 6.1.320.0 ??)
    Runtime : v2.0.50727

    Can you check if this is the same for you ? (its on both my development pc's)

    Could you mail me your project from the example ? (bjoern_mikkelsen @ hotmail.com)

    I have search the ADCenter for issues but have found none that fixes this issue.

    Thanks for the help.

    Tuesday, April 24, 2012 12:17 AM
  • One thing, when I look in Visual Studio and want to add the Microsoft.Advertising.Mobile.Xna reference it say it has :
    Version : 6.1.0.0 (shouldnt this be 6.1.320.0 ??)
    Runtime : v2.0.50727


    I see these values in the IDE also.  However if you look at the dll's properties using file explorer, you should 6.1.320.0 in the details tab.

    Wednesday, April 25, 2012 9:50 PM
  • The dll's have version 6.1.320.0 under details.

    Can I send you my project so you can check if it works for you ?

    Can it be a setting in Visual Studio (Using Visual Studio 2010 Premium) ? my regional settings ? date/time format ? etc.

    I have a game all completed, just waiting for ads to be added before it can be submittet, so its very frustrating that it doesnt work :(

    Thanks again for the time/help


    Wednesday, April 25, 2012 11:07 PM
  • Update:
      I have been testing outside of Microsoft network and I have a consistent repro now.

      In the case where the Ad fails to display I am seeing a web exception, after about 30 seconds.

      Start the app with debugger attached (F5) and let it run for about 1 minute then check if you see the debug output like the following:

    A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

    A first chance exception of type 'System.Net.WebException' occurred in System.Windows.dll

    A first chance exception of type 'System.Net.WebException' occurred in System.Windows.dll

    A first chance exception of type 'System.Net.WebException' occurred in Microsoft.Advertising.Mobile.dll


    Wednesday, April 25, 2012 11:14 PM
  • Hi Eric

    Good to hear you can reproduce it.

    Yes I see the same 4 web exceptions.
    But I cant seem to figure out what they mean ?

    Wednesday, April 25, 2012 11:36 PM
  • Basically, the Ad control is trying to download the image, or text, to display.
    The exceptions are thrown because no server responds to the request.

    The Ad control handles the exception so you only see the first chance warning in the output but since it could not get a resource to display it does not draw itself.

    The problem may be limited to using "test_client" for the applicationID ...but I'm not sure yet.
     
    Tomorrow, I'll get network traces from the PC in my office to check if the URL I'm seeing in my current repro matches what my desktop is using.

    (https://mobileads-test.msn.com/v3/Delivery/Placement?pubid=test_client&pid=Image480_80&...)
    Wednesday, April 25, 2012 11:54 PM
  • Thanks alot for the help, Im looking forward to hear what you find :)
    Thursday, April 26, 2012 12:05 AM
  • I tried to put in my ad unit ID and application ID instead of "test_client" and "Image480x80" and now I get this error :

    A first chance exception of type 'Microsoft.Advertising.Shared.AdException' occurred in Microsoft.Advertising.Mobile.dll

    Thursday, April 26, 2012 12:21 AM
  • Were you running on a device or in the emulator?
    (Live Ads won't work in the emulator with the new Ad SDK...)

    FYI:
    I verified that my PC at work is using the same URL.  Also the same code on my laptop which was failing outside of the Microsoft network runs ok inside the network so there appears to be something about the Microsoft corporate proxy which allows this to work.  It could be that the proxy is redirecting the request to an internal server or that the Ad server is only responding to requests for test content which originate from a Microsoft IP address.


    Thursday, April 26, 2012 3:17 PM
  • Hi Eric

    Im now using my AppID and AdUnit ID from AD Center.

    Edit : Its seems that i works but VERY rare, like 1/50 times I start the application. And it seems its always the same ad that is showed.

    If I do this I get the following results :

    Connected to PC using Zune:
    Target : Windows Phone Device : Debug = Works,real ads showing but VERY rare, most of the times it doesnt work.
    Target : Windows Phone Device : Release =
    A first chance exception of type 'Microsoft.Advertising.Shared.AdException' occurred in Microsoft.Advertising.Mobile.dll

     

     

    Not connected to PC/Zune
    Deploy : Windows Phone Device : Doesnt work

    :(

    Regards
    Bjorn

    Thursday, April 26, 2012 4:40 PM
  • To get more information about the error, add an event handler for "ErrorOccurred"
    and check the AdErrorEventArgs for details:

    bannerAd.ErrorOccurred += new EventHandler<Microsoft.Advertising.AdErrorEventArgs>(bannerAd_ErrorOccurred);


    void bannerAd_ErrorOccurred(object sender, Microsoft.Advertising.AdErrorEventArgs e)
    {
        // ToDo: Check e.ErrorCode...
        // ToDo: Check e.Error...
    }
    Thursday, April 26, 2012 6:14 PM
  • Hi Eric

    After adding the EventHandler for errors, I get the following output in the app :

    ErrorCode : ServerSideError
    ErrorText : No ad available

    I havent specified any keywords, location etc. (just using the basic ad example with my App Id / Unit ID)
    On https://pubcenter.microsoft.com/ I have added 3 categories.

    Anything I might be missing ?

    Thursday, April 26, 2012 6:47 PM
  • Anything I might be missing ?


    Not that I know of but you've reached the limit of my knowledge regarding the Ad SDK.
    You may want to try asking on the Microsoft pubCenter for Mobile forums.
    Thursday, April 26, 2012 7:43 PM
  • Hi Eric

    I will do that. Now I see ads sometimes, which means the code must be correct.

    Thank you VERY much for helping on this issue.

    Brgds
    Bjorn
    Thursday, April 26, 2012 7:46 PM
  • I am experiencing the exact same problem with my XNA and MS Addvertising SDK 6.1.320
    The Ad control simply does not show up on the UI. I created a default Windows Phone Game (4.0) and followed the steps given in http://msdn.microsoft.com/en-us/library/advertising-mobile-windows-phone-7-xna-api(v=msads.20).aspx
    Even tried it on two devices (Samsung Focus & Nokia Lumia 900), the Ad control does not show up.
    Sunday, April 29, 2012 4:15 AM
  • Hi Tony

    After getting help from Eric I have been investigating this problem more.

    Heres what I have found out :

    If I add the code Eric provided that adds an eventhandler I get an error saying "ServerSideError : No ads available".
    The reason I get this is that Im in a "low amount of ad country", in my case Denmark, Europe.

    This means that people who will download you app/game in a country with alot of ads (UK, US etc.) will see ads.
    To fix this do :

    1. put this line in your code (red line):

     

     

    AdGameComponent.Initialize(this, AdAppId); 

     

     

    AdGameComponent.Current.CountryOrRegion = System.Globalization.RegionInfo.CurrentRegion.TwoLetterISORegionName;

     

    Components.Add(

     

     

    AdGameComponent.Current);

     

    CreateAd();

    What is does is tell ADCenter to deliver ads based on your phones regional settings. If you dont have this the regional settings is set based on you IP address (I think).

    2. Deploy the app/game to your device
    3. Set your Regional settings on your phone to US or UK and restart your phone
    4. Start your app/game and you will see the ads

    One thing, dont try this with "test_client" / "Image480_80" since it seems there is a bug with this. Get a real AppID and UnitID from ADCenter and use those. Also never test on the emulator, always on a physical device.

    So basically your code works, its ADCenter that is the "problem". As more phones is sold in the various countries, more ads will come etc.

    One strange problem I have is that when I enable ads and have my regional settings to Denmark and start my app then about 1/5 times it will reboot the phone ! If I set my regional settings to UK/US or disable ads I starts every time. This is REALLY bad as it gives the user of both my app/game AND Windows Phone a bad experience :(

    Regards
    Bjorn

     

    Sunday, April 29, 2012 11:06 AM
  • Thank you very much!
    Adding the following line helped: AdGameComponent.Current.CountryOrRegion = System.Globalization.RegionInfo.CurrentRegion.TwoLetterISORegionName;
    The "test+client"/ "Image480_80" simply does nto work for XNA and new Ad version 6.1. Its too bad that MS did not test this before releasing it to the public.

    I am in US and my phone is already set to US region. After adding the CountryOrRegion information my ads started appearing.
    Sunday, April 29, 2012 3:37 PM
  • Update:
      The issue regarding test_client ads not showing up, outside of Microsoft network, should be fixed now.
    Wednesday, May 2, 2012 4:46 PM
  • Thank you for the update.
    Wednesday, May 2, 2012 5:15 PM
  • Hi Eric

    Thank you for the update :)

    Wednesday, May 2, 2012 5:31 PM
  • I cant get the ads to show on my new game but when i compile with my old game the ads show. Both games use the same code for displaying ads any idea on why this is happening?
    Thursday, May 3, 2012 11:17 PM
  • I also have this issue. The ad example c# code does not show an ad in the emulator or on my device (lumia 900), I also tried the ad I created in the pubcenter, but this does not show up on the device either. In addition, I added the AdGameComponent.Current.CountryOrRegion = System.Globalization.RegionInfo.CurrentRegion.TwoLetterISORegionName;
    line which does not help my situation. I'm in the US.

    exception immediately thrown at runtime:

    A first chance exception of type 'Microsoft.Advertising.Shared.AdException' occurred in Microsoft.Advertising.Mobile.dll

    Friday, May 11, 2012 6:56 PM
  • I am using windows phone sdk 7.1 and the ad sdk 6.1.320 from http://www.microsoft.com/en-us/download/details.aspx?id=8729
    In the debug I got another line out giving more information about the error (this is the ad sdk example I'm using):

    A first chance exception of type 'Microsoft.Advertising.Shared.AdException' occurred in Microsoft.Advertising.Mobile.dll
    Ad error: This version of the ad control is not compatible with 7.0 apps.

     

    //*********************************************************  
    //  
    // Copyright (c) Microsoft. All rights reserved.  
    // This code is licensed under the Microsoft Public License.  
    // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF  
    // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY  
    // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR  
    // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.  
    //  
    //*********************************************************  
    using System;  
    using System.Collections.Generic;  
    using System.Linq;  
    using Microsoft.Xna.Framework;  
    using Microsoft.Xna.Framework.Audio;  
    using Microsoft.Xna.Framework.Content;  
    using Microsoft.Xna.Framework.GamerServices;  
    using Microsoft.Xna.Framework.Graphics;  
    using Microsoft.Xna.Framework.Input;  
    using Microsoft.Xna.Framework.Input.Touch;  
    using Microsoft.Xna.Framework.Media;  
    using Microsoft.Advertising.Mobile.Xna;  
    using System.Diagnostics;  
    using System.Device.Location;  
     
    namespace XnaGameWithAd  
    {  
        /// <summary>  
        /// This is the main type for your game  
        /// </summary>  
        public class Game1 : Microsoft.Xna.Framework.Game  
        {  
            private static readonly string ApplicationId = "test_client";  
            private static readonly string AdUnitId = "Image480_80"//other test values: Image480_80, Image300_50, TextAd  
            
            GraphicsDeviceManager graphics;  
            SpriteBatch spriteBatch;  
            DrawableAd bannerAd;  
     
            // We will use this to find the device location for better ad targeting.  
            private GeoCoordinateWatcher gcw = null;  
     
            public Game1()  
            {  
                graphics = new GraphicsDeviceManager(this);  
                Content.RootDirectory = "Content";  
     
                // Frame rate is 30 fps by default for Windows Phone.  
                TargetElapsedTime = TimeSpan.FromTicks(333333);              
            }  
     
            /// <summary>  
            /// Allows the game to perform any initialization it needs to before starting to run.  
            /// This is where it can query for any required services and load any non-graphic  
            /// related content.  Calling base.Initialize will enumerate through any components  
            /// and initialize them as well.  
            /// </summary>  
            protected override void Initialize()  
            {  
                // Initialize the AdGameComponent with your ApplicationId and add it to the game.  
                AdGameComponent.Initialize(this, ApplicationId);  
                Components.Add(AdGameComponent.Current);  
                AdGameComponent.Current.CountryOrRegion = System.Globalization.RegionInfo.CurrentRegion.TwoLetterISORegionName;   
     
                // Now create an actual ad for display.  
                CreateAd();  
     
                base.Initialize();  
            }  
     
            /// <summary>  
            /// LoadContent will be called once per game and is the place to load  
            /// all of your content.  
            /// </summary>  
            protected override void LoadContent()  
            {  
                // Create a new SpriteBatch, which can be used to draw textures.  
                spriteBatch = new SpriteBatch(GraphicsDevice);  
     
                // TODO: use this.Content to load your game content here  
            }  
     
            /// <summary>  
            /// UnloadContent will be called once per game and is the place to unload  
            /// all content.  
            /// </summary>  
            protected override void UnloadContent()  
            {  
                // TODO: Unload any non ContentManager content here  
            }  
     
            /// <summary>  
            /// Allows the game to run logic such as updating the world,  
            /// checking for collisions, gathering input, and playing audio.  
            /// </summary>  
            /// <param name="gameTime">Provides a snapshot of timing values.</param>  
            protected override void Update(GameTime gameTime)  
            {  
                // Allows the game to exit  
                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)  
                    this.Exit();  
     
                // TODO: Add your update logic here  
     
                base.Update(gameTime);  
            }  
     
            /// <summary>  
            /// This is called when the game should draw itself.  
            /// </summary>  
            /// <param name="gameTime">Provides a snapshot of timing values.</param>  
            protected override void Draw(GameTime gameTime)  
            {  
                GraphicsDevice.Clear(Color.CornflowerBlue);  
     
                // TODO: Add your drawing code here  
     
                base.Draw(gameTime);  
            }  
     
            /// <summary>  
            /// Create a DrawableAd with desired properties.  
            /// </summary>  
            private void CreateAd()  
            {  
                // Create a banner ad for the game.  
                int width = 480;  
                int height = 80;  
                int x = (GraphicsDevice.Viewport.Bounds.Width - width) / 2; // centered on the display  
                int y = 5;  
                  
                bannerAd = AdGameComponent.Current.CreateAd(AdUnitId, new Rectangle(x, y, width, height), true);  
                  
                // Add handlers for events (optional).  
                bannerAd.ErrorOccurred += new EventHandler<Microsoft.Advertising.AdErrorEventArgs>(bannerAd_ErrorOccurred);  
                bannerAd.AdRefreshed += new EventHandler(bannerAd_AdRefreshed);  
     
                // Set some visual properties (optional).  
                bannerAd.BorderEnabled = true// default is true  
                bannerAd.BorderColor = Color.White; // default is White  
                bannerAd.DropShadowEnabled = true// default is true  
     
                // Provide the location to the ad for better targeting (optional).  
                // This is done by starting a GeoCoordinateWatcher and waiting for the location to be available.  
                // The callback will set the location into the ad.   
                // Note: The location may not be available in time for the first ad request.  
                AdGameComponent.Current.Enabled = false;  
                this.gcw = new GeoCoordinateWatcher();  
                this.gcw.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(gcw_PositionChanged);  
                this.gcw.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(gcw_StatusChanged);  
                this.gcw.Start();  
            }  
     
            /// <summary>  
            /// This is called whenever a new ad is received by the ad client.  
            /// </summary>  
            /// <param name="sender"></param>  
            /// <param name="e"></param>  
            private void bannerAd_AdRefreshed(object sender, EventArgs e)  
            {  
                Debug.WriteLine("Ad received successfully");  
            }  
     
            /// <summary>  
            /// This is called when an error occurs during the retrieval of an ad.  
            /// </summary>  
            /// <param name="sender"></param>  
            /// <param name="e">Contains the Error that occurred.</param>  
            private void bannerAd_ErrorOccurred(object sender, Microsoft.Advertising.AdErrorEventArgs e)  
            {  
                Debug.WriteLine("Ad error: " + e.Error.Message);  
            }  
                    
            private void gcw_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)  
            {  
                // Stop the GeoCoordinateWatcher now that we have the device location.  
                this.gcw.Stop();  
     
                bannerAd.LocationLatitude = e.Position.Location.Latitude;  
                bannerAd.LocationLongitude = e.Position.Location.Longitude;  
     
                AdGameComponent.Current.Enabled = true;  
     
                Debug.WriteLine("Device lat/long: " + e.Position.Location.Latitude + ", " + e.Position.Location.Longitude);  
            }  
     
            private void gcw_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)  
            {  
                if (e.Status == GeoPositionStatus.Disabled || e.Status == GeoPositionStatus.NoData)  
                {     
                    // in the case that location services are not enabled or there is no data  
                    // enable ads anyway  
                    AdGameComponent.Current.Enabled = true;  
                    Debug.WriteLine("GeoCoordinateWatcher Status :" + e.Status);                  
                }  
            }  
     
            /// <summary>  
            /// Clean up the GeoCoordinateWatcher  
            /// </summary>  
            protected override void Dispose(bool disposing)  
            {  
                base.Dispose(disposing);  
     
                if (disposing)  
                {  
                    if (this.gcw != null)  
                    {  
                        this.gcw.Dispose();  
                        this.gcw = null;  
                    }  
                }  
            }  
        }  
    }  
     

    Friday, May 11, 2012 7:22 PM
  • Here is my code and it works just fine on the Phone (Focus and Nokia 900).

      private void CreateAd()
            {
                // Create a banner ad for the game.
                int x = 200;
                int y = 400;
                int width = 480;
                int height = 80;
                AdGameComponent.Initialize(this, applicationId);
                AdGameComponent.Current.CountryOrRegion = System.Globalization.RegionInfo.CurrentRegion.TwoLetterISORegionName;
                Components.Add(AdGameComponent.Current);
                bannerAd = AdGameComponent.Current.CreateAd(adUnitId, new Rectangle(x, y, width, height), true);
            }
    Sunday, May 13, 2012 11:30 PM
  • still getting these issues, even using your code (which is basically the same of what the example has). so strange that i cannot get the ads to work. if i set up the error handler for the bannerad i get a more verbose error:

    Ad error: This version of the ad control is not compatible with 7.0 apps.


    this really makes no sense why it should not work. i've uninstalled and redownloaded and reinstalled the ad sdk to no avail. really discouraging :(

    Monday, May 14, 2012 2:32 PM
  • Have you tried asking this question on the the Microsoft Advertising support forum?
    (http://community.microsoftadvertising.com/forums/32.aspx)
    Monday, May 14, 2012 3:31 PM
  • When I created the XNA appliation I had targeted it for Windows Phone OS 7.1 (Mango).
    Since the error indicates that ad control is not compatible with 7.0, I believe you project might still be configured to target Windows Phone OS 7.0 and not 7.1. Try changing it to 7.0 and see if it helps. 

    Also do a Build > Clean Solution and if required delete the Debug and Release directories under bin. When I upgraded from older Ad SDK to the newer one, I had to delete by Debug and Release directory as it refused to delete the old Ad DLLs. I also had to re-add the new Ad SDK DLL reference to project. Not sure if it helps.
    Good Luck.

    Monday, May 14, 2012 3:57 PM
  • Thanks for the help everyone, this lead me to solving the issue. the example project I used needed to be upgraded, my actual project (while not needing an upgrade) started working as well and my guess is last time I tried it the advertising server was down (I read this in a recent post somewhere.)

    For anyone that's curious, to find out if a project needs upgrading right click the project name (the one in bold, underneath the solution name in the solution explorer) and you'll see an option to upgrade the project. You could also check this in the project properties list by clicking the project name and seeing what OS it is configured for. The example advertisement projects are configured for 7.0 and thus do not inherently work with the current SDK.
    Tuesday, May 15, 2012 3:18 PM
  • I just upgraded from 7.1 to 7.1.1 and have the same issue more or less. I don't get the specfic message about upgrading from 7.0 though as i had already upgrade to 7.1. I get this set of exceptions in the debug output:

     

    A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

    A first chance exception of type 'System.Net.WebException' occurred in System.Windows.dll

    A first chance exception of type 'System.Net.WebException' occurred in System.Windows.dll

    A first chance exception of type 'System.Net.WebException' occurred in Microsoft.Advertising.Mobile.dll

    I have also even completely uninstalled and re-installed everything, rolled back my code to a previous backup, cleared the debug/release directories manually, and still am unable to get the ad control to show. I've even played with permissions and specifically running as administrator to ensure no funky UAC might be happening. I'm now back to just 7.1, and the 5.2 version of the advertising control that comes with it, and still no luck.

    Would really appreciate some help on this one, I have no idea what could have changed.

     

    Thursday, May 24, 2012 1:04 PM
  • I just upgraded from 7.1 to 7.1.1 and have the same issue more or less. I don't get the specfic message about upgrading from 7.0 though as i had already upgrade to 7.1. I get this set of exceptions in the debug output:

     

    A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

    A first chance exception of type 'System.Net.WebException' occurred in System.Windows.dll

    A first chance exception of type 'System.Net.WebException' occurred in System.Windows.dll

    A first chance exception of type 'System.Net.WebException' occurred in Microsoft.Advertising.Mobile.dll

    I have also even completely uninstalled and re-installed everything, rolled back my code to a previous backup, cleared the debug/release directories manually, and still am unable to get the ad control to show. I've even played with permissions and specifically running as administrator to ensure no funky UAC might be happening. I'm now back to just 7.1, and the 5.2 version of the advertising control that comes with it, and still no luck.

    Would really appreciate some help on this one, I have no idea what could have changed.

     

     



    I got the same error message several hours ago. It then suddenly turned fine for a few hours for no reason. Now I get this exception:

    A first chance exception of type 'Microsoft.Advertising.Shared.AdException' occurred in Microsoft.Advertising.Mobile.dll

    Since there is literally zero change to my code, I strongly believe that Microsoft is running some patches or updates on their server.

    Thursday, May 24, 2012 6:21 PM
  • Use the ErrorOccurred event to get more information regarding the failure.
    Thursday, May 24, 2012 6:25 PM
  • Now I get:

    AdException occured: "Mandatory title for text ad not found."

    How do fix this?

    The code I'm using, if it matters. Note the exact code works just 4 hours ago.
    AdGameComponent.Initialize(this"test_client");  
    bannerAd = AdGameComponent.Current.CreateAd("Image480_80"new Rectangle(0, 720, 480, 80), true);  
    Components.Add(AdGameComponent.Current); 
    Thursday, May 24, 2012 7:19 PM
  • I'm having issues too suddenly, but this is in regards to even the test ad not displaying. Was working fine for a few days, did some menu clean up, etc, and since last night it's not displaying anymore. Figured maybe something was wrong on the MS end, and it'd be fixed in the morning. Still nothing.
    Thursday, May 24, 2012 10:24 PM
  • I was able to reproduce the problem.
    I do not yet know the cause but I have forwarded the error report internally.

    Thursday, May 24, 2012 10:58 PM
  • I saw that there might have been some issue with the server over on the Microsoft Advertising Forums. I have my ads back now, but not sure if it was because i rolled back to the 7.1 installation or not. I'm installing the 7.1.1 update again to check.

    [Updated] Yep, all working now, must have been a server issue.
    Saturday, May 26, 2012 2:49 AM
  • HI,

    I'm seeing this issue every time I navigate to an XAML page with the adControl on.  I'm using the SDK v7.1.1 and I'm in the UK.

    The message is exactly the same as everyone else;

    A first chance exception of type 'Microsoft.Advertising.Shared.AdException' occurred in Microsoft.Advertising.Mobile.dll

    Anyone know how to fix would help me lots!
    Saturday, June 23, 2012 6:26 PM
  • Hi,
    Can you please go to Debug->Exceptions in your VS project and check the Thrown box for Common Language Runtime Exception? This way you can report the callstack.

    -Mark
    Monday, June 25, 2012 5:52 PM
  • Do you get anything in the ErrorOccurred event?

    ex:
    private void adControl1_ErrorOccurred(object sender, Microsoft.Advertising.AdErrorEventArgs e)  
    {  
        System.Diagnostics.Debug.WriteLine("Ad Error ({0}) \"{1}\"", e.ErrorCode, e.Error.Message);  
    }  
    Tuesday, July 3, 2012 3:37 PM
  • There are lots.  Although, it seems like your question has pretty much been answered XD
    Wednesday, July 4, 2012 12:20 AM
  • Mark/Eric

    Apologies for the delay in replying - this is what i get in the error event:

    A first chance exception of type 'Microsoft.Advertising.Shared.AdException' occurred in Microsoft.Advertising.Mobile.dll
    Step into: Stepping over method without symbols 'Microsoft.Advertising.AdErrorEventArgs.ErrorCode.get'
    Step into: Stepping over method without symbols 'Microsoft.Advertising.AdErrorEventArgs.Error.get'
    Step into: Stepping over method without symbols 'System.Exception.Message.get'
    Step into: Stepping over method without symbols 'System.Diagnostics.Debug.WriteLine'
    Ad Error (ServerSideError) "Invalid value for parameter (Name: w)."

    and this is the call stack:

    > WP7_CashTrack.dll!WP7_CashTrack.MainPage.adBought_ErrorOccurred(object sender, Microsoft.Advertising.AdErrorEventArgs e) Line 707 C#
      mscorlib.dll!System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo rtmi, object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object parameters, System.Globalization.CultureInfo culture, bool isBinderDefault, System.Reflection.Assembly caller, bool verifyAccess, ref System.Threading.StackCrawlMark stackMark)
      mscorlib.dll!System.Reflection.RuntimeMethodInfo.InternalInvoke(object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object[] parameters, System.Globalization.CultureInfo culture, ref System.Threading.StackCrawlMark stackMark) + 0x168 bytes
      mscorlib.dll!System.Reflection.MethodBase.Invoke(object obj, object[] parameters) + 0xa bytes
      mscorlib.dll!System.Delegate.DynamicInvokeOne(object[] args) + 0x98 bytes
      mscorlib.dll!System.MulticastDelegate.DynamicInvokeImpl(object[] args) + 0x8 bytes
      mscorlib.dll!System.Delegate.DynamicInvoke(object[] args) + 0x2 bytes
      System.Windows.dll!System.Windows.Threading.DispatcherOperation.Invoke() + 0xc bytes
      System.Windows.dll!System.Windows.Threading.Dispatcher.Dispatch(System.Windows.Threading.DispatcherPriority priority) + 0x83 bytes
      System.Windows.dll!System.Windows.Threading.Dispatcher.OnInvoke(object context) + 0x8 bytes
      System.Windows.dll!System.Windows.Hosting.CallbackCookie.Invoke(object[] args) + 0x19 bytes
      System.Windows.dll!System.Windows.Hosting.DelegateWrapper.InternalInvoke(object[] args) + 0x2 bytes
      System.Windows.RuntimeHost.dll!System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(System.IntPtr pHandle, int nParamCount, System.Windows.Hosting.NativeMethods.ScriptParam[] pParams, ref System.Windows.Hosting.NativeMethods.ScriptParam pResult) + 0x5e bytes


    The strange thing is that I have used the ad control on a different XAML page with the same parameters and it works fine.

    Any ideas???
    Monday, July 9, 2012 7:10 PM
  • Ad Error (ServerSideError) "Invalid value for parameter (Name: w)."

    I don't know what parameter 'w' is but my first guess is: width...
    It's just a guess but maybe the size of the control is too small?  (...or too large?)
    Monday, July 9, 2012 7:44 PM
  • Hi,

    I thought that too, but I don't have any parameters used starting with "w", my ad control definition looks like this:

    <my:AdControl x:Name="adBought" IsAutoCollapseEnabled="False" Height="80" AdUnitId="xxxxx" ApplicationId="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" ErrorOccurred="adBought_ErrorOccurred" />
    
    
    Not sure what it is!

    Note: Just found this, http://community.microsoftadvertising.com/en/developer/pubcenter/f/32/t/71746.aspx, it looks like I need to have a width property.

    Tried it and it seems to fix the problem.
    Monday, July 9, 2012 9:29 PM