Two Things You Need to Know About Microsoft Advertising SDK in WinRT

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:
Known Issues – AdControl for Windows 8.1:

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#/ 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):

(2) In Visual Studio, select PROJECT | Manage NuGet Packages. In the Online section, select 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
Like this:

       ocrEngine = new OcrEngine(OcrLanguage.English);
}catch(Exception ex)
       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:

        <Extension Category="windows.activatableClass.inProcessServer">
                <ActivatableClass ActivatableClassId="WindowsPreview.Media.Ocr.OcrEngine" ThreadingModel="both" />

One thought on “Two Things You Need to Know About Microsoft Advertising SDK in WinRT”

Leave a Reply to Paul Ishak Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>