我使用InnerActive作爲默認廣告提供給我的Windows Phone應用程序。我從2013年6月開始使用它,在我年底的分析中,我意識到InnerActive廣告是我的應用程序崩潰的主要來源。最糟糕的部分是,它的代碼不我沒有任何控制權。我已經爲每一個請求Inneractive Ads的操作放置了一個「try catch」。Inneractive Ads會導致很多應用程序崩潰(Windows Phone)
有沒有人有任何想法我該如何解決這個問題?
哪裏是我用來請求廣告代碼:
private void LoadInnerActiveAds()
{
try
{
if (DeviceNetworkInformation.IsNetworkAvailable)
{
// Watch location
if (_allowAdLocationTracker)
{
IaLocationClass iaLocation = new IaLocationClass();
iaLocation.Done += new EventHandler<IaLocationEventArgs>(InnerActiveLocation_Done);
iaLocation.StartWatchLocation();
}
optionalParams = new Dictionary<InneractiveAd.IaOptionalParams, string>();
//optionalParams.Add(InneractiveAd.IaOptionalParams.Key_Gender, "m");
optionalParams.Add(InneractiveAd.IaOptionalParams.Key_Ad_Alignment, InneractiveAd.IaAdAlignment.CENTER.ToString());
optionalParams.Add(InneractiveAd.IaOptionalParams.Key_OptionalAdWidth, "480");
optionalParams.Add(InneractiveAd.IaOptionalParams.Key_OptionalAdHeight, "80");
}
//Show Add Banner. Remarks: pay attention to use Application Id from NAX
//naxAd.Childred.Count()==0 => just to add one banner control on a page. Without this, code would add as many banners as you navigate to page where banner is placed
if (optionalParams != null && AdsUIContainer.Children.Count == 0)
{
InneractiveAd iaBanner = new InneractiveAd(AdsAppId, InneractiveAd.IaAdType.IaAdType_Banner, 30, optionalParams);
iaBanner.AdFailed += new InneractiveAd.IaAdFailed(InneractiveAd_AdFailed);
Deployment.Current.Dispatcher.BeginInvoke(() => { UpdateUI(iaBanner); });
}
}
catch (Exception ex)
{
InneractiveAd_AdFailed(ex);
}
}
該堆棧跟蹤可能會有所幫助,但請記住,這是代碼,我無法控制。
Frame Image Function Offset
0 system_xml_ni System.Xml.XmlTextReaderImpl.Throw 0x00000036
1 system_xml_ni System.Xml.XmlTextReaderImpl.ParseDocumentContent 0x00000438
2 system_xml_ni System.Xml.XmlTextReaderImpl.Read 0x00000036
3 system_xml_ni System.Xml.XmlReader.ReadToFollowing 0x0000003c
4 inneractive_ad_ni Inneractive.Ad.InneractiveAdControl.ParseCPDXml 0x0000007c
5 inneractive_ad_ni Inneractive.Ad.InneractiveAdControl.webClient_UploadStringCompleted 0x000000aa
6 system_net_ni System.Net.WebClient.OnUploadStringCompleted 0x00000010
7 system_net_ni System.Net.WebClient.UploadStringOperationCompleted 0x00000034
解決方案:
繼Soonts的建議,這是我想出了:
在App.xaml.cs文件中找到 「Application_UnhandledException」 方法,取而代之的是:
// Code to execute on Unhandled Exceptions
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
if (e.ExceptionObject.StackTrace.Contains("Inneractive.Ad.InneractiveAdControl"))
{
// Recover from the error
e.Handled = true;
return;
}
if (Debugger.IsAttached)
{
// An unhandled exception has occurred; break into the debugger
Debugger.Break();
}
}
請讓我k現在如果你找到更好的選擇。
再次感謝Soonts。我會試試看。這將是一個痛苦的考驗。 –