Issue with DefaultHouseAd - help needed

Feb 2, 2014 at 5:04 PM
Edited Feb 2, 2014 at 5:11 PM
Following the guides I've tried to create my DefaultHouseAd control but it is not shown.

Here is the control:
<UserControl x:Class="nE2Control.LocalControls.AdDefaultAdv"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             FontFamily="{StaticResource PhoneFontFamilyNormal}"
             FontSize="{StaticResource PhoneFontSizeNormal}"
             d:DesignHeight="90"
             d:DesignWidth="490"
             Width="Auto"
             >

    <Grid x:Name="LayoutRoot"
          >
        <HyperlinkButton HorizontalAlignment="Center" Margin="5" VerticalAlignment="Center" Height="Auto" Width="Auto" NavigateUri="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2CXKWCLNN2QCJ" TargetName="_blank" >
            <HyperlinkButton.Background>
                <ImageBrush x:Name="Brush" Stretch="None" ImageSource=""/>
            </HyperlinkButton.Background>
        </HyperlinkButton>
    </Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Resources;
using System.Windows.Shapes;
using Microsoft.Advertising;
using Microsoft.Advertising.Mobile.UI;
using nE2Control.Resources;


namespace nE2Control.LocalControls
{
    public partial class AdDefaultAdv : UserControl
    {
        public AdDefaultAdv()
        {
                InitializeComponent();
                Brush.ImageSource = new BitmapImage(
                    new Uri(@LibResources.PayPal, UriKind.Relative)
                );
                ;
        }
    }
}
Quite trivial, I have a Hyperlink button and an image in the bottom that is dynamically loaded at control creation.

To test it I changed my defaultAdSettings.xml to be:
<?xml version="1.0" encoding="utf-8"?>
<AdSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <CultureDescriptors>
  <AdCultureDescriptor CultureName="default">
      <Probabilities Probability="0" AdType="Smaato" AppID="xxx" SecondaryID="xxx"/>
      <Probabilities Probability="0" AdType="AdMob" AppID="xxx"/>
      <Probabilities Probability="0" AdType="InnerActive" AppID="xxx" />
      <Probabilities Probability="0" AdType="MobFox" AppID="xxx" IsTest="false"/>
      <Probabilities Probability="0" AdType="PubCenter" AppID="xxx" SecondaryID="xxx" />
      <Probabilities Probability="0" AdType="AdDuplex" AppID="xxx"/>
      <Probabilities Probability="100" AdType="DefaultHouseAd" AppID="nE2Control.LocalControls.AdDefaultAdv"/>
    </AdCultureDescriptor>

  </CultureDescriptors>
</AdSettings>
As explained in the
   private void AdControlOnLoaded(object sender, RoutedEventArgs routedEventArgs)
I added the line
                adControl.DefaultHouseAdBody = "nE2Control.LocalControls.AdDefaultAdv";
and to show all messages I've added a debug print on the Log event.

Here is the outcome:

AdControl : Failed loading Default HouseAd
AdControl : Ads failed request for: DefaultHouseAd
AdControl : DefaultHouseAd Created
AdControl : Ads being served for: DefaultHouseAd
AdControl : Ads being served for: DefaultHouseAd


This is a set of printouts I've added in the code in the loaded even after the Invalidate to check that the xml file is read correctly:
AdControl : DefaultHouseAdBody = nE2Control.LocalControls.AdDefaultAdv
AdControl : Smaato = xxx- xxx
AdControl : AdMob AdUnitID = xxx
AdControl : Inneractive AppID = xxx
AdControl : MobFox AppID = xxx
AdControl : PubCenter = xxx - xxx
AdControl : AdDuplex AppID = xxx


And here we are back with the log:

AdControl : Ads are enabled for display
AdControl : Ads being requested for: None
AdControl : No ads available


What am I doing wrong? why is not working? any idea or help?


Note:
is some guides I've found this:
AdRotatorSilverlight.DefaultHouseAdBody = new nE2Control.LocalControls.AdDefaultAdv();
but is wrong as DefaultHouseAdBody is a string while nE2Control.LocalControls.AdDefaultAdv is an object of type UserControl
Feb 2, 2014 at 5:19 PM
Edited Feb 2, 2014 at 5:23 PM
Also is there a way to force to show the HouseAd for debug purposes? The AdRotator sample project never shows it even if I give it a 100% probability and 0 to the others.

I'm using AdRotator v1.0.3 (as reported from nuget)
Coordinator
Feb 3, 2014 at 10:15 AM
You config does look ok (note you don't have to configure against the control, just in the config XML)

You are correct the latest version of the control should use a string.

two things to try:
  1. load your user house ad user control on a separate page manually to ensure it loads and displays correctly
  2. Try updating to the beta version 1.1.0 of the V1 control (V2 does not yet have house ads)
Comparing your config above to the sample in source, I cannot see anything obvious why your project isn't working.
Feb 5, 2014 at 9:06 PM
Edited Feb 5, 2014 at 9:25 PM
I did 1 and everything worked (well had to fix some issues :) )

Found how to update to 1.1.0 Beta.

The AdDefaultAdv now is even easier than before:
<UserControl x:Class="nE2Control.LocalControls.AdDefaultAdv"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             FontFamily="{StaticResource PhoneFontFamilyNormal}"
             FontSize="{StaticResource PhoneFontSizeNormal}"
             d:DesignHeight="90"
             d:DesignWidth="490"
             Width="Auto"
             DataContext="{Binding Adv, Source={StaticResource Locator}}">

    <Grid x:Name="LayoutRoot">

        <Image Stretch="None" HorizontalAlignment="Center"  VerticalAlignment="Center" Width="480" Height="80" Source="{Binding PayPalImg}" />
        <HyperlinkButton HorizontalAlignment="Center" VerticalAlignment="Center" Height="80" Width="480" NavigateUri="..." TargetName="_blank" >
        </HyperlinkButton>

    </Grid>
</UserControl>
But still does not work :(

_AdControl : DefaultHouseAdBody = nE2Control.LocalControls.AdDefaultAdv
A first chance exception of type 'System.NullReferenceException' occurred in AdRotator.dll
AdControl : ERROR Loaded - NullReferenceException
AdControl : Ads are enabled for display
AdControl : Ads being requested for: DefaultHouseAd
A first chance exception of type 'System.InvalidOperationException' occurred in System.dll
AdControl : Failed loading Default HouseAd
AdControl : Ads failed request for: DefaultHouseAd
AdControl : DefaultHouseAd Created
AdControl : Ads being served for: DefaultHouseAd
AdControl : Ads are enabled for display
AdControl : Ads being requested for: None
AdControl : Ads being served for: None
_

So is even worst gthen before :(
M
Feb 5, 2014 at 9:38 PM
Additional info 1.1.0 -pre
does not work on my project. The AdRemote gives an error in XAML :(

So 1.0.3 is shown correctly in my AdControl but does not load my custom Ad
1.1.0 beta does not work
Feb 5, 2014 at 10:37 PM
Edited Feb 5, 2014 at 10:37 PM
I put back 1.0.3 and now I'm again at:

AdControl : Failed loading Default HouseAd
AdControl : Ads failed request for: DefaultHouseAd
AdControl : DefaultHouseAd Created
AdControl : Ads being served for: DefaultHouseAd
AdControl : Ads being served for: DefaultHouseAd
AdControl : DefaultHouseAdBody = nE2Control.LocalControls.AdDefaultAdv
AdControl : Smaato = xxxxx- xxx
AdControl : AdMob AdUnitID = xxxx
AdControl : Inneractive AppID = xxx
AdControl : MobFox AppID = xxx
AdControl : PubCenter = xxx - xxx
AdControl : AdDuplex AppID = xxx
AdControl : Ads are enabled for display
AdControl : Ads being requested for: None
AdControl : No ads available