This is the XAML you can get from Microsoft Ads SDK sample. According
to the documentation, put this block of code in your page and replace the ApplicationId with
the id you get from PubCenter by register your app for the ads purpose:
<StackPanel Grid.Row="3"
Grid.ColumnSpan="3" Background="{StaticResource
MSAdsBackgroundThemeBrush}" Orientation="Vertical">
<UI:AdControl
ApplicationId="4d075f8c-2db3-4484-ac37-6e446da687bd"
AdUnitId="150628"
Width="728"
Height="90"
Margin="0,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"/>
</StackPanel>
But from time to time, if you pay attention to the output
view when your app is running. You can find the following messages:
A first chance exception of type
'MicrosoftAdvertising.Shared.AdException' occurred in
MicrosoftAdvertising.winmd
A first chance exception of type 'MicrosoftAdvertising.Shared.AdException' occurred in MicrosoftAdvertising.winmd
A first chance exception of type 'MicrosoftAdvertising.Shared.AdException' occurred in mscorlib.dll
A first chance exception of type 'MicrosoftAdvertising.Shared.AdException' occurred in MicrosoftAdvertising.winmd
A first chance exception of type 'MicrosoftAdvertising.Shared.AdException' occurred in mscorlib.dll
Sometimes it is led by some error message like this:
A first chance exception of type
'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.Http.HttpRequestException' occurred in mscorlib.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.Http.HttpRequestException' occurred in mscorlib.dll
Even your app does not access network at all. The interesting
this is you still get to see ads in your app.
Then I put some code in my page to catch the error
condition:
<UI:AdControl
ApplicationId="4d075f8c-2db3-4484-ac37-6e446da687bd"
AdUnitId="150628"
Width="728"
Height="90"
Margin="0,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Bottom" ErrorOccurred="AdControl_ErrorOccurred"/>
private void AdControl_ErrorOccurred(object sender, Microsoft.Advertising.WinRT.UI.AdErrorEventArgs e)
{
Debug.WriteLine(String.Format("Spelling
Champion Message AdControl Error
Exception: {0}; AdControl Error Code {1}",
e.Error.Message, e.ErrorCode.ToString()));
}
Then I run the app again, I got the exception.message as “No ad available”
and the error code is NoAdAvailable.
Remember that the app still show ads, so “NoAdAvailable” is not
true.
This is my guess:
The Ads control fires HTTP calls to pull contents from
Ads service. When certain call is not success, it throws Http exception. But as long as some important pieces of information
is collected, it will show the ads. This exception is either some kind of debugging
info should be removed but not or this is a indication that something is wrong
in MS Ads service/Coontrol.
I filed a ticket to MS, when I get response back I will
post it here.
No comments:
Post a Comment