除了在尝试展示广告时

时间:2016-01-16 19:52:31

标签: c# exception interop

我试图在调用事件时显示广告,使用以下代码:

using Microsoft.Advertising.WinRT.UI;
.
.
private InterstitialAd ad;
.
.
Interop.RequestInterstitialEvent += Interop_RequestInterstitialEvent;
Interop.ShowInterstitialEvent += Interop_ShowInterstitialEvent;
.
.
.
void Interop_RequestInterstitialEvent(object sender, EventArgs e)
{  //When I want to recharge ad
    ad = new InterstitialAd();
    ad.RequestAd(AdType.Video, "d25517cb-12d4-4699-8bdc-52040c712cab", "11389925");
}

void Interop_ShowInterstitialEvent(object sender, EventArgs e)
{ // Show your ad only if it is charging
    if (ad.State == InterstitialAdState.Ready)
    {
        ad.Show();
    }
}

显示以下错误: Error

确定何时在Ready相同的工作后不久显示公告:

void Interop_RequestInterstitialEvent(object sender, EventArgs e)
{
    ad = new InterstitialAd();
    ad.RequestAd(AdType.Video, "d25517cb-12d4-4699-8bdc-52040c712cab", "11389925");
    ad.AdReady += ad_AdReady;
}

void ad_AdReady(object sender, object e)
{
    ad.Show();
}

但我想只在我致电Interop_ShowInterstitialEvent时才显示它。如何在该事件中显示它?

0 个答案:

没有答案