I have an UWP app which displays several catalogs of videos. They are located in separate pages. For this purpose I've created an NativeAdV2
control:
public sealed partial class CardAdvert : UserControl
{
NativeAdsManagerV2 manager = new NativeAdsManagerV2("d25517cb-12d4-4699-8bdc-52040c712cab", "test");
NativeAdV2 advert;
public CardAdvert()
{
InitializeComponent();
manager.AdReady += AdReady;
manager.RequestAd();
}
private void AdReady(object sender, NativeAdReadyEventArgs e)
{
advert = e.NativeAd;
Initialize();
e.NativeAd.RegisterAdContainer(this); //Exception is here
}
public void Initialize()
{
title.Text = advert.Title;
image.Source = new BitmapImage(advert.MainImages.First().Url.ToUri());
if (advert.AdIcon == null)
contentGrid.ColumnDefinitions[0].Width = new GridLength(0);
else
icon.ProfilePicture = advert.AdIcon.Source;
if (string.IsNullOrWhiteSpace(advert.SponsoredBy))
sponsor.Visibility = Visibility.Collapsed;
else
sponsor.Text = advert.SponsoredBy;
if (!string.IsNullOrWhiteSpace(advert.Rating))
info.Text += $" {advert.Rating}";
if (string.IsNullOrWhiteSpace(advert.CallToActionText) && string.IsNullOrWhiteSpace(advert.Price))
desc.Visibility = Visibility.Collapsed;
else if (!string.IsNullOrWhiteSpace(advert.CallToActionText))
desc.Text = advert.CallToActionText;
else
desc.Text = advert.Price;
}
}
But no matter where I create it (even on different page) on the second or third time it throws me an exception on e.NativeAd.RegisterAdContainer(this)
:
Unhandled exception at 0x082A1330 (Windows.UI.Xaml.dll) in FoxTube.exe:
0xC000027B: An application-internal exception has occurred (parameters: 0x1E9F4608, 0x00000003)
There is no anything similar neither on MSDN forum or elsewhere nor in NativeAdV2 class documentation
Perfectly, I'd like to insert this control every 10 videos. Or at least on every page. Is there any solutions?
Actually, I don't know why Microsoft doesn't want to fix this but as they said it works on earlier builds. You just need to downgrade your target and minimal versions to 17134 and it will work. You can also use Windows UI Library to get latest XAML controls
User contributions licensed under CC BY-SA 3.0