Share using Windows Runtime Components
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
With Windows Runtime components, you can now mix programming languages and API technologies to build the apps you envision.
This topic contains the following sections.
The following list describes when you should consider sharing functionality of your app in Windows Runtime Component.
Harnessing the power of C++: If your app carries out computationally intensive operations, you might opt to write that code in C++ to achieve optimal performance. If the code that uses this functionality is written in C# or VB, you can package the functionality as a Windows Runtime Component and call the component from your managed code.
Crossing language boundaries: In general, using a Windows Runtime Component is a great way to expose your code to all supported languages. This is not necessary if your app is written in one language and you don’t intend to expose any of your functionality to other languages. Instead you can compose your app of regular class libraries, Portable Class Libraries or, depending on the size and complexity of your app, just write the whole app in the same project.
Using Direct3D, Win32, or COM APIs: Windows Phone 8 delivers native API to enable powerful gaming scenarios, native networking and access to camera API from native code. To use these API from managed code, you can wrap this functionality in a Windows Runtime Component. For more info, see Supported Win32 APIs for Windows Phone 8 and Games for Windows Phone 8.
Using third-party libraries: In the past, it was difficult to consume a third-party library, written in one language, if your app written in another language. With Windows Runtime Components, it is possible to grab a library, wrap it in a Windows Runtime Component and expose the functionality to your app written in any supported language.
The preceding list is some of the scenarios where writing a Windows Runtime Component is a very useful way of sharing code. However, a Windows Runtime Component is not a standard DLL or assembly. There are very specific requirements you must follow when creating a Windows Runtime Component. These requirements include using only allowed data types, handling collections, creating only sealed classes and many more. Visual Studio will help at compile time, and indicate clearly when something goes wrong.
The language in which you can write a Windows Runtime Component and the languages that can consume a Windows Runtime Component vary for each platform. The following table summarizes what is supported on Windows Phone 8 and what is supported on Windows 8.
Windows Phone 8
C++, C#, VB
C++, C#, VB