积极答复者
动态添加adControl之后adControl不能显示的问题

问题
-
为了解决微软一个组件的BUG
Frame Image Function Offset
0 coredll.dll xxx_RaiseException 19
1 mscoree3_7.dll 520892
2 mscoree3_7.dll 461967
3 mscoree3_7.dll 534468
4 TransitionStub 0
5 Microsoft.Advertising.Mobile.Shared.WebRequestWrapper.WebRespCallback 652
6 .__c__DisplayClassa._InvokeGetResponseCallback_b__8 76
7 .WorkItem.WaitCallback_Context 104
8 System.Threading.ExecutionContext.Run 324
9 .WorkItem.doWork 220
10 System.Threading.Timer.ring 296
11 mscoree3_7.dll 507848
12 mscoree3_7.dll 509212
13 mscoree3_7.dll 440663
14 mscoree3_7.dll 440417
15 mscoree3_7.dll 439375
16 mscoree3_7.dll 317155
17 coredll.dll ThreadBaseFunc 144
1. 更新了AdControl到最新版,2012/03/21发布的6.1.320.0
2. 担心微软没能彻底解决问题,所以用动态adControl
XAML某个地方的StackPanel
<StackPanel Grid.Row="0" Name="adPanel" Width="480" Height="80" Margin="0,0,0,4"></StackPanel>
CodeBehind:
private AdControl adControl;
public MainPage()
{
InitializeComponent();
// adControl is programmatically added to the page as the following code illustrates.
adControl = GetNewAdControl();
adControl.ErrorOccurred += OnAdErrorOccurred;
adControl.AdRefreshed += OnAdRefreshed;}
// Returns a new AdControl
private AdControl GetNewAdControl()
{
return new AdControl("xxxxxxxx-ff3a-49b9-8d55-xxxxxxxxxxxx", "#####", true)
{
Width = 480,
Height = 80,
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Bottom
};
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// AdPanel is a StackPanel control in this page's XAML layout page.
if (!adPanel.Children.Contains(adControl))
{
adPanel.Children.Add(adControl);
}
base.OnNavigatedTo(e);
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
// AdPanel is a StackPanel control in this page's XAML layout page.
if (adPanel.Children.Contains(adControl))
{
adPanel.Children.Remove(adControl);
}
base.OnNavigatedFrom(e);
}但现在运行后显示一片空白,啥都没有。
答案
-
您好,
我这边使用测试的AdUnitId和ApplicationId测试是可以正常显示出AdControl的。
请查看你的AdUnitId 和ApplicationId设置的是否正确。
以下是我的测试代码,请参考:
private AdControl GetNewAdControl()
{
return new AdControl("test_client", "Image480_80", true)
{
Width = 480,
Height = 80,
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Bottom
};
}- 已标记为答案 Shi Ding 2012年6月28日 17:08
全部回复
-
您好,
我这边使用测试的AdUnitId和ApplicationId测试是可以正常显示出AdControl的。
请查看你的AdUnitId 和ApplicationId设置的是否正确。
以下是我的测试代码,请参考:
private AdControl GetNewAdControl()
{
return new AdControl("test_client", "Image480_80", true)
{
Width = 480,
Height = 80,
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Bottom
};
}- 已标记为答案 Shi Ding 2012年6月28日 17:08