The Microsoft Advertising SDKs allow developers to show ads in their apps (Windows Phone/Windows Store apps). With these SDKs developers can create apps that present a rich and engaging advertising experience for their users.
Microsoft has pointed out some known issues in MSDN document:
Known Issues – Microsoft Advertising SDK for Windows Phone: https://msdn.microsoft.com/en-us/library/advertising-mobile-windows-phone-known-issues(v=msads.20).aspx
Known Issues – AdControl for Windows 8.1: https://msdn.microsoft.com/en-us/library/advertising-windows-known-issues%28v=msads.10%29.aspx
Recently, we have got some feedbacks from our customers, this article will describe two things which not be clearly mentioned in the above two documents.
1. The page navigating will stop working in C++ Hub App after adding the Microsoft Advertising AdControl
A customer created a C++ HUB demo using VS template and added ADControl, he encountered a weird issue when navigating to other page with this exception:
Microsoft C++ exception: Platform::FailureException ^ at memory location 0x0140E560. HRESULT:0×80004005 Unspecified error
It will cause app crashing. This issue does not exist in C#/Vb.net Hub app
The most likely explanation is mentioned in the “Known Issues – AdControl for Windows 8.1” document:
No Native Support: The current Ad SDK does support .NET C++ (managed C++ using the CLR). The AdControl loads the CLR and uses managed C++. Fully native support is planned for a future release — there is no release ETA.
The workaround is just setting Window::Current::Content directly instead of using Frame->Navigate method
2. “OcrEngine is not registered” exception when creating a new OcrEngine instance
(1) Download the official Microsoft OCR Library Sample(C# version): https://code.msdn.microsoft.com/Uses-the-OCR-Library-to-2a9f5bf4
(2) In Visual Studio, select PROJECT | Manage NuGet Packages. In the Online section, select nuget.org. Search for Microsoft.Windows.Ocr. Click Install.
(3) Add reference to “Microsoft Advertising SDK for Windows Phone 8.1 (XAML)” and set Windows Phone as the Start project
(4) Add Try Catch structure outside of this line: ocrEngine = new OcrEngine(OcrLanguage.English); in the Scenario1_ExtractTest.xaml.cs file
ocrEngine = new OcrEngine(OcrLanguage.English);
Debug.WriteLine(ex.Message); //Add break point at here
(5) Start debugging on the emulator, everything will be fine
(6) Now debug on the real device, click on scenario select button, you will see the error message:
This issue is not caused by the Advertising SDK, an expert from Microsoft OCR Team has pointed out that it seems like classes are not being pulled out of the winmd file for insertion into the final .appxmanifest file. It looks like a known issue with VS 2013 Update 4 that should be fixed with Update 5.
The workaround is to add extension entry for OcrEngine class manually to the .appxmanifest file:
<ActivatableClass ActivatableClassId="WindowsPreview.Media.Ocr.OcrEngine" ThreadingModel="both" />