×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Registered User
    Join Date
    Sep 2013
    Posts
    45

    AdControl not working in my project

    As in the title, I can't get the AdControl to work in my project.

    It loads fine in an empty project, but in the one that I'm using it throws a
    Code:
    TypeInitializationException
    that has a
    Code:
    ObjectDisposedException: Cannot access a disposed object. Object name:"native Object"
    as inner exception.

    I've never seen anything like this and I've no idea on what this means!

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2011
    Location
    Portugal
    Posts
    945

    Re: AdControl not working in my project

    Do you have a stack trace?

  3. #3
    Registered User
    Join Date
    Sep 2013
    Posts
    45

    Re: AdControl not working in my project

    Here are some more infos:

    XamlParseException: [Line: 0 Position: 0]
    > StackTrace :
    in MS.Internal.XcpImports.CheckParserHResult(UInt32 hr)
    in MS.Internal.XcpImports.FrameworkElement_ApplyTemplate(FrameworkElement frameworkElement)
    in System.Windows.Controls.Control.ApplyTemplate()
    > InnerException: TypeInitializationException: L'inizializzatore di tipo di 'Microsoft.Advertising.AdManager' ha generato un'eccezione. (this should mean something like "The type initializer of 'Microsoft.Advertising.AdManager' generated an exception)
    > > StackTrace:
    in Microsoft.Advertising.AdManager.get_Current()
    in Microsoft.Advertising.Mobile.UI.AdControl.InitializeAdControl()
    in Microsoft.Advertising.Mobile.UI.AdControl.OnApplyTemplate()
    in System.Windows.FrameworkElement.OnApplyTemplate(IntPtr nativeTarget)
    > > InnerException: ObjectDisposedException: Impossibile accedere a un oggetto eliminato. Nome oggetto: 'NativeObject'. (this should mean "Cannot access a disposed object. Object name:'NativeObject'")
    > > > StackTrace:
    in System.Windows.DependencyObject.MS.Internal.IManagedPeerBase.get_NativeObject()
    in MS.Internal.XcpImports.GetValue(IManagedPeerBase managedPeer, DependencyProperty property)
    in System.Windows.DependencyObject.GetValueInternal(DependencyProperty dp)
    in System.Windows.Deployment.get_EntryPointAssembly()
    in Microsoft.Advertising.AdManager.SetExceptionMessagesCulture()
    in Microsoft.Advertising.AdManager..cctor()

  4. #4
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    686

    Re: AdControl not working in my project

    Hmmm what is the order of those exceptions?
    To me it seems like the 2 later exceptions are a result of the first exception which is due to a faulty xaml file.
    Did you declare the AdControl namespace in the xaml? did you make sure to add a reference to the binary or nuget package?
    If you try to open the xaml file with the xaml gui editor are you able to see the page or are you getting an error screen (if you see an error screen its 100% a faulty xaml file and you should check it)

  5. #5
    Registered User
    Join Date
    Sep 2013
    Posts
    45

    Re: AdControl not working in my project

    The first is the root exception, the second one is the InnerException of the first, and the third is the InnerException of the first.

    I'm dragging the control by hand, so namespace and stuff like that is done automatically.
    I can't see the control in the XAML designer, and hovering it with the mouse shows the "Cannot access a disposed object. Object name:'NativeObject'" exception.

    I've got this error even using the default page of the Data Bound Application template

  6. #6
    Registered User
    Join Date
    Sep 2013
    Posts
    45

    Re: AdControl not working in my project

    A quick update to let you know that I still can't get it work, even after updating th AD SDK to the latest version (6.2.960.0)

  7. #7
    Nokia Developer Champion
    Join Date
    Feb 2013
    Location
    Dublin, Ireland
    Posts
    552

    Re: AdControl not working in my project

    What code is being added to your project?

  8. #8
    Registered User
    Join Date
    Sep 2013
    Posts
    45

    Re: AdControl not working in my project

    xmlns:ui="clr-namespace:Microsoft.Advertising.Mobile.UI;assembly=Microsoft.Advertising.Mobile.UI"
    ...
    <ui:AdControl/>
    That's all

  9. #9
    Nokia Developer Champion
    Join Date
    Feb 2013
    Location
    Dublin, Ireland
    Posts
    552

    Re: AdControl not working in my project

    Some controls have required parameters. From looking at this Wiki tutorial, I'd guess AdUnitId and ApplicationId are required, but it's always good to copy from up-to-date working examples.

    http://developer.nokia.com/Community...ows_Phone_apps

  10. #10
    Registered User
    Join Date
    Sep 2013
    Posts
    45

    Re: AdControl not working in my project

    I used an old code which is quite similar to the one in the link you provided and the test ad is showing but I still have the error in the XAML designer o.O

  11. #11
    Nokia Developer Champion
    Join Date
    Feb 2013
    Location
    Dublin, Ireland
    Posts
    552

    Re: AdControl not working in my project

    Run-time errors are all that matter, the design-time view often comes up with errors - and it's wrong.

    Successful builds also don't guarantee valid XAML. You always have to test in the simulator or on device to be sure.

  12. #12
    Registered User
    Join Date
    Aug 2013
    Posts
    3

    Re: AdControl not working in my project

    Try AdDuplex. Its great and easy to use.
    Windows Phone 8 AdControl Installation and Usage

    AdDuplex control for Windows Phone 8 is hosted on nuget.org.

    To add AdDuplex AdControl to your Windows Phone 8 XAML based project do the following:

    Go to Tools -> Library Package Manager -> Package Manager Console
    Run the Install-Package command:

    PM> Install-Package AdDuplexWP8


    Alternatively you can install the control via NuGet UI:

    Right-click on your project
    Click on "Manage NuGet Packages..."
    In the Online portion search for "AdDuplexWP8" and click install
    To start participating in the exchange:

    Register your Windows Phone app in AdDuplex system and write down your AppId.
    Add a namespace declaration to your Page

    xmlns:adduplex="clr-namespace:AdDuplex;assembly=AdDuplex.WindowsPhone"


    Add AdControl to your page:

    <adduplex:AdControl x:Name="adDuplexAd"
    AppId="YOUR_AppId_HERE"
    />


    Make sure the whole AdControl is visible by verifying that it's not obstructed by any other objects on your page.
    You can preview your own exchange ad by setting IsTest property to true.

Similar Threads

  1. [Help] Demo project working in Simulator but not in device
    By sirajsoft in forum Nokia Asha Web Apps
    Replies: 0
    Last Post: 2013-06-02, 08:52
  2. help me:working with polish project
    By safa55 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2012-03-25, 07:06
  3. Replies: 4
    Last Post: 2010-08-05, 10:30
  4. Working SIP project
    By tom_symbian in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2005-07-26, 09:51

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×