Windows手机广告无效

tha*_*guy 12 windows-phone-7

我正在尝试将广告整合到已经成功部署的应用中.但无论我做什么,我似乎无法让广告正常运作.我尝试过使用代码版本和drag n'drop gui版本.我都不能开始工作.

这就是我所看到的:当它启动时,它可能会闪烁一瞬间白色,广告应该是,但不过没有,没有添加.它识别它放在我放置的位置,当我将它放在按钮上时,按钮变得不可点击.总而言之,没有默认的"微软广告"图像弹出.我已经安装了广告SDK,并且已经成功地轻松地在其他项目中展示广告.

是什么赋予了?这是非常简单的页面,我无法弄清楚出了什么问题.我似乎也无法在任何其他页面上放置广告......我确实拥有Microsoft.Advertising.Mobile和Microsoft.Advertising.Mobile.UI包含在项目中,我的互联网正在运行(我有一个项目同时打开广告,它的工作原理)

<phone:PhoneApplicationPage 
    x:Class="AppName.AdPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True"
    xmlns:my="clr-namespace:Microsoft.Advertising.Mobile.UI;assembly=Microsoft.Advertising.Mobile.UI">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Margin="12,17,12,28">
            <TextBlock x:Name="PageTitle" Text="Thank You!" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" Width="334" />
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0" Height="569" VerticalAlignment="Top">

            <Button Content="Ok" Height="72" HorizontalAlignment="Center" Margin="0,428,0,0" Name="button1" VerticalAlignment="Top" Width="160" Click="button1_Click" />
            <my:AdControl AdUnitId="Image480_80" ApplicationId="test_client" Height="80" HorizontalAlignment="Left" Margin="-12,458,0,0" Name="adControl1" VerticalAlignment="Top" Width="480" />
        </Grid>
    </Grid>
</phone:PhoneApplicationPage>
Run Code Online (Sandbox Code Playgroud)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Advertising.Mobile.UI;
using Microsoft.Advertising.Mobile;
namespace Stickey_Note_v._1
{
    public partial class AdPage : PhoneApplicationPage
    {
        public AdPage()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

Jos*_*arl 20

我有同样的问题,写了一篇关于它的博客文章.这是重要的东西:

SDK的问题的症状AdControl似乎非常一致:页面加载,控件短暂闪烁,显示1像素帧的提示,然后,poof.它崩溃成虚无,只留下一个绝望的黑洞.

从理论上讲,设置AdControl很简单.Microsoft文档概述了基础知识:

  • 下载并安装Microsoft Advertising SDK.
  • 添加引用Microsoft.Advertising.Mobile.UI.
  • 将控件拖到Visual Studio设计器中的页面上.
  • AdUnitIdApplicationId属性设置为测试值或实际实时值,您可以从Microsoft pubCenter获取.

但它不是那么容易.我仔细地按照文档,但没有任何工作.我甚至无法展示测试广告,这看起来很奇怪.我甚至还原到我的应用程序的旧版本(yay source control!)并放入新的.dll中.失败.

最后,我在一篇不起眼的论坛帖子中找到了一条线索.

Microsoft文档忽略了几个重要细节.如果您要将现有项目升级到Mango广告SDK,则需要特别注意以下事项:

  • 您必须指定高度和宽度AdControl.如果未指定HeightWidth属性,或将其设置为auto,将导致沮丧的泪水.我推荐80像素高,480像素宽,因为这是微软提供的广告的原生大小.
  • 看来你不能AdControls在同一页面上有两个,或者至少不能在同一个父元素中.第二个将崩溃.可能有一种解决方法,但我在构建我的演示应用程序时发现它并不关心寻求解决方案.
  • 您必须必须在WMAppManifest.xml文件中指定某些功能.由于我正在升级我的应用程序,因此我没有声明一些较新的功能.导致所有麻烦的那个是ID_CAP_IDENTITY_USER.控件正常运行需要以下功能:
<Capabilities>
    <Capability Name="ID_CAP_IDENTITY_USER"/>
    <Capability Name="ID_CAP_MEDIALIB"/>
    <Capability Name="ID_CAP_NETWORKING"/>
    <Capability Name="ID_CAP_PHONEDIALER"/>
    <Capability Name="ID_CAP_WEBBROWSERCOMPONENT"/>
</Capabilities>
Run Code Online (Sandbox Code Playgroud)

希望有所帮助!