Search code examples
windows-8windows-runtimewindows-phone-8portable-class-library

Choosing Windows Runtime Components versus Portable Code Library


When sharing code between Windows Phone 8 and Windows 8, the two core options for developers are 1) Windows Runtime Components and 2) Portal Class Libraries.

Windows Runtime Components use WinRT and can be projected into all the supported languages. They require linked files in separate projects (binaries) when used on different platforms. They, however, share 90% of the available WinRT APIs.

Portable Class Libraries are a subset (sometimes a significant subset) of the BCL that has binary compatibility across platforms. They can be used on WinRT applications but also on other project types like Silverlight, Xbox, etc.

When a developer is choosing a "sharing strategy" which project type is the go-to technique to do the best job sharing code between Windows Phone 8 and Windows 8? Thanks.


Solution

  • If you want to share code between Windows Phone 8 and Windows 8, then you cannot use Windows Runtime Components, because there are different components used for Windows 8 and different for Windows Phone 8 and they are not interchangeable.
    I would go for either Portable Class Libraries for some simple generic libraries, or for code sharing via links and #if WP8 compilation directives - this just works and is more powerful than Portable libs.
    Keep also in mind that most external libraries like MVVM Light cannot be referenced in Portable Libs, so if you want to use them, you have to use the code sharing via file references.