2014-12-23 114 views
3

我开发了一个Windows Phone 8.1应用程序,我想添加Google ad mob增加到它。我按照这个link中的说明添加了GoogleAds.dll到我的Windows Phone 8.1引用中,但是在工具中我找到了AdView控件。我正在使用VS2013快递。将谷歌广告添加到Windows Phone 8.1应用程序

我也试过C#代码。

{ 
    AdView bannerAd = new AdView 
      { 
         Format = AdFormats.BANNER, 
         AdUnitID = "MY_AD_UNIT_ID" 
      }; 

       AdRequest adRequest = new AdRequest(); 
      _mygrid.Children.Add(bannerAd); 
      bannerAd.LoadAd(adRequest); 
    } 

其中_mygrid是一个网格。我可以将Adview控制器添加到网格吗?

当我尝试建立我收到以下错误

错误1型“System.Windows.Controls.UserControl”在没有引用的组件定义的解决方案。您必须添加对程序集“System.Windows,Version = 2.0.6.0,Culture = neutral,PublicKeyToken = 7cec85d7bea7798e”的引用。 c:\ users \ makot \ documents \ visual studio 2013 \ Projects \ WC \ WC \ MainPage.xaml.cs

错误2为'Windows.UI.Xaml.Controls.UIElementCollection.Add(Windows .UI.Xaml.UIElement)'有一些无效参数c:\ users \ makot \ documents \ visual studio 2013 \ Projects \ WC \ WC \ MainPage.xaml.cs

错误3参数1:无法从'GoogleAds .AdView'改为'Windows.UI.Xaml.UIElement'c:\ users \ makot \ documents \ visual studio 2013 \ Projects \ WC \ WC \ MainPage.xaml.cs

+0

您是否试过直接输入XAML而不是从工具箱中拖动?如果您的引用设置正确,并且在XAML中声明了相关的名称空间,它应该可以正常工作。也许这个更详细的指南将有助于http://www.windowsapptutorials.com/windows-phone/advertising/how-to-use-google-admob-in-windows-phone-app/ – pumpkinszwan

+0

我试着添加followong XAML代码< GoogleAds:AdView AdUnitID =“MY_AD_UNIT_ID”Format =“MY_AD_FORMAT”/>但它说没有找到类型“GoogleAds:AdView”。你的指南最终会导致我在上面发布的同一页面。我可以在VS的对象浏览器中看到GoogleADS dll的所有类,但是我怎么会无法在项目中使用它。我是否在添加dll之后错过任何操作? – Manikanta

+0

你的项目是否有对dll的参考?右键单击项目,添加>参考>选择'解决方案',然后确保Google广告项目被选中并带有小点号。 – pumpkinszwan

回答

2

Google Ad mob SDK目前支持Silverlight(WP8 /WP8.1 Silverlight)。虽然你可以参考提到的DLL到WP8.1 RT项目,但它不起作用。

相关问题