Windows phone 8 无法在windows phone 8中集成Microsoft广告sdk

Windows phone 8 无法在windows phone 8中集成Microsoft广告sdk,windows-phone-8,Windows Phone 8,我无法将adcontrol集成到我的windows phone 8应用程序中。 在windows phone 8中,参考中已经提供了microsoft广告sdk,因此没有下载相同的sdk。 下面是我使用的代码片段: // Constructor public MainPage() { InitializeComponent(); // ApplicationID = "test_client", AdUnitID = "Image480_80",

我无法将adcontrol集成到我的windows phone 8应用程序中。 在windows phone 8中,参考中已经提供了microsoft广告sdk,因此没有下载相同的sdk。 下面是我使用的代码片段:

// Constructor
    public MainPage()
    {
        InitializeComponent();

        // ApplicationID = "test_client", AdUnitID = "Image480_80", 

        AdControl adControl = new AdControl("test_client",   // ApplicationID
                                            "Image480_80",   // AdUnitID
                                            true);           // isAutoRefreshEnabled
        // Make the AdControl size large enough that it can contain the image
        adControl.Width = 480;
        adControl.Height = 80;

        Grid grid = (Grid)this.LayoutRoot.Children[1];
        grid.Children.Add(adControl);            
    }
我还添加了本链接中提到的各种功能:

但我仍然没有运气…在一个地方,我读到你需要有互联网连接,以使adcontrol可见。这是真的吗

无论如何,在这方面需要帮助


提前谢谢

假设您正确地完成了所有其他需求内容,并下载了Microsoft Ads SDK并将其添加到参考中

主页顶部

using Microsoft.Advertising.Mobile.UI;
在MainPage类中初始化这些

Grid adGrid = new Grid();
StackPanel adStackPanel = new StackPanel();
AdControl adControl = new AdControl("test_client", "Image480_80", true);
在构造函数中,您可以这样做

adControl.Width = 480;
adControl.Height = 80;
adStackPanel.Children.Insert(0, adControl);
adGrid.Children.Insert(0, adStackPanel);
adGrid.HorizontalAlignment = HorizontalAlignment.Right;
adGrid.VerticalAlignment = VerticalAlignment.Bottom;
this.DrawingSurfaceBackground.Children.Insert(0, adGrid);


//Optional
adControl.ErrorOccurred += adControl_ErrorOccurred;
void adControl_ErrorOccurred(object sender, Microsoft.Advertising.AdErrorEventArgs e)
        {
            try
            {
                AdControl ad = (AdControl)sender;

                Dispatcher.BeginInvoke(() =>
                {
                    // MessageBox.Show(e.Error.ToString());
                    Debug.WriteLine(

           "error in ad control '" + ad.Name + "': " + e.Error.Message);

                    Debug.WriteLine("ad control '" + ad.Name + "' visibility = " + ad.Visibility);
                });

            }

            catch (Exception evnt)
            {
                Debug.WriteLine("oh no! " + evnt.Message);
            }
        }

假设您正确地完成了所有其他需求,并下载了Microsoft Ads SDK并将其添加到参考中

主页顶部

using Microsoft.Advertising.Mobile.UI;
在MainPage类中初始化这些

Grid adGrid = new Grid();
StackPanel adStackPanel = new StackPanel();
AdControl adControl = new AdControl("test_client", "Image480_80", true);
在构造函数中,您可以这样做

adControl.Width = 480;
adControl.Height = 80;
adStackPanel.Children.Insert(0, adControl);
adGrid.Children.Insert(0, adStackPanel);
adGrid.HorizontalAlignment = HorizontalAlignment.Right;
adGrid.VerticalAlignment = VerticalAlignment.Bottom;
this.DrawingSurfaceBackground.Children.Insert(0, adGrid);


//Optional
adControl.ErrorOccurred += adControl_ErrorOccurred;
void adControl_ErrorOccurred(object sender, Microsoft.Advertising.AdErrorEventArgs e)
        {
            try
            {
                AdControl ad = (AdControl)sender;

                Dispatcher.BeginInvoke(() =>
                {
                    // MessageBox.Show(e.Error.ToString());
                    Debug.WriteLine(

           "error in ad control '" + ad.Name + "': " + e.Error.Message);

                    Debug.WriteLine("ad control '" + ad.Name + "' visibility = " + ad.Visibility);
                });

            }

            catch (Exception evnt)
            {
                Debug.WriteLine("oh no! " + evnt.Message);
            }
        }
解决方案:

我在您的问题中发现的问题是功能,请记住,功能从windows phone-7更改为windows phone-8

您添加的功能符合windows phone-7(正如您在链接中提到的)

您可以在以下位置找到所需的功能:

样本:

    public MainPage()
    {
        InitializeComponent();
        AdControl adCntrl = new AdControl();
        adCntrl.Height = 80;
        adCntrl.Width = 480;
        adCntrl.ApplicationId = "test_client";
        adCntrl.AdUnitId = "Image480_80";
        ContentPanel.Children.Add(adCntrl);
    }
具备以下能力:

<Capabilities>
  <Capability Name="ID_CAP_IDENTITY_USER"/>
  <Capability Name="ID_CAP_MEDIALIB_PHOTO"/>
  <Capability Name="ID_CAP_NETWORKING"/>
  <Capability Name="ID_CAP_PHONEDIALER"/>
  <Capability Name="ID_CAP_WEBBROWSERCOMPONENT"/>
  <Capability Name="ID_CAP_MEDIALIB_AUDIO"/>
  <Capability Name="ID_CAP_MEDIALIB_PLAYBACK"/>
  <Capability Name="ID_CAP_SENSORS"/>
</Capabilities>

解决方案:

我在您的问题中发现的问题是功能,请记住,功能从windows phone-7更改为windows phone-8

您添加的功能符合windows phone-7(正如您在链接中提到的)

您可以在以下位置找到所需的功能:

样本:

    public MainPage()
    {
        InitializeComponent();
        AdControl adCntrl = new AdControl();
        adCntrl.Height = 80;
        adCntrl.Width = 480;
        adCntrl.ApplicationId = "test_client";
        adCntrl.AdUnitId = "Image480_80";
        ContentPanel.Children.Add(adCntrl);
    }
具备以下能力:

<Capabilities>
  <Capability Name="ID_CAP_IDENTITY_USER"/>
  <Capability Name="ID_CAP_MEDIALIB_PHOTO"/>
  <Capability Name="ID_CAP_NETWORKING"/>
  <Capability Name="ID_CAP_PHONEDIALER"/>
  <Capability Name="ID_CAP_WEBBROWSERCOMPONENT"/>
  <Capability Name="ID_CAP_MEDIALIB_AUDIO"/>
  <Capability Name="ID_CAP_MEDIALIB_PLAYBACK"/>
  <Capability Name="ID_CAP_SENSORS"/>
</Capabilities>


任何人在同一方面有任何帮助…我面临着类似的问题,我尝试了两种方法,但酒吧中心的广告根本不起作用。任何人在同一方面有任何帮助…我面临着类似的问题,我尝试了两种方法,但酒吧中心的广告根本不起作用。