Admob插页式广告整合错误

时间:2015-11-26 16:48:44

标签: c# windows-phone-8 admob

我有以下代码。我正在尝试在我的应用程序中集成admob插页式广告。下面的代码运行良好,应用程序也运行良好。但是,在运行应用程序后,我遇到了很大的麻烦。该应用程序正在退出而不会抛出任何异常。我没有广告就运行了应用程序,并没有给我这样的错误。请帮忙解决这个问题。

 private InterstitialAd interstitial;
        private AdRequest adRequest;

        public About_us()
        {
            InitializeComponent();
            ApplicationBar = new ApplicationBar();
            ApplicationBar.Mode = ApplicationBarMode.Minimized;
            ApplicationBar.IsVisible = true;
            ApplicationBar.IsMenuEnabled = true;


            ApplicationBarIconButton menu = new ApplicationBarIconButton();


            menu.IconUri = new Uri("/images/menu.png", UriKind.Relative);

            menu.Text = "Menu";


            ApplicationBar.Buttons.Add(menu);



            menu.Click += new EventHandler(MenuBtn);

            interstitial = new InterstitialAd("ca-app-pub-3870621720639923/4928477699");
            adRequest = new AdRequest();
            //Enable test ads.
            adRequest.ForceTesting = true;

            interstitial.FailedToReceiveAd += OnFailedToReceiveAd;
            interstitial.DismissingOverlay += OnDismissingOverlay;
            interstitial.ReceivedAd += OnAdReceived;
            interstitial.LoadAd(adRequest);


        }

        private void OnDismissingOverlay(object sender, AdEventArgs e)
        {
            // throw new NotImplementedException();
            Debug.WriteLine("Ad dismissed.");
            interstitial.LoadAd(adRequest);
        }

        private void OnFailedToReceiveAd(object sender, AdErrorEventArgs e)
        {
            // MessageBox.Show("Ad not received");
            Debug.WriteLine("Ad failed to load!!!!");

        }

        private void OnAdReceived(object sender, AdEventArgs e)
        {
            interstitial.ShowAd();
            System.Diagnostics.Debug.WriteLine("Ad received successfully");


        }

1 个答案:

答案 0 :(得分:0)

尝试:       adRequest = new AdRequest.Builder()。Build();