Adrotator unable to catch Ad not found exception for Pubcenter

57 Views Asked by At

Currently this gets caught in App.xaml.cs
Message: Error Message: System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. ---> MicrosoftAdvertising.Shared.AdException: No ad available.

How can i catch this exception in code or should AdRotator handle it?

I can share more code if this is not a known issue.

1

There are 1 best solutions below

3
On
<UI:AdControl Name="mainHeaderAd" IsAutoRefreshEnabled="True" ErrorOccurred="AdControl_ErrorOccurred" AdUnitId="xxx" ApplicationId="yyy" />

This is how I am handling AdControl exceptions:

private void AdControl_ErrorOccurred(object sender, Microsoft.Advertising.WinRT.UI.AdErrorEventArgs e)
    {
        try
        {
            var errorType = Enum.GetName(typeof(MicrosoftAdvertising.ErrorCode), e.ErrorCode);

            var adControl = sender as Microsoft.Advertising.WinRT.UI.AdControl;

            // Do something with the above information.
        }
        catch (Exception ex)
        {
           // Do something with the exception.
        }
    }