Make WinRT API usable in Portable Class Libraries targeting Windows 8 and WP8
Windows 8 API and Windows Phone 8 API is both based on Windows Runtime and it shares lot of common code. For some strange reason it's not possible to use any WinRT classes in Portable Class Libraries targeting Windows 8 and WP8.
Please make it possible for us developers to use classes like StorageFile, StorageFolder and others in PCL libraries to make the code reusability even better, thanks!
That’s a great suggestion. We’ve added this capability for the new versions of both platforms. So when you author a portable class libraries with the following targets (or any subset) you’ll have access to WinRT APIs as well:
- Windows 8.1
- Windows Phone 8.1
- Windows Phone Silverlight 8.1
For the first two platforms, you’re also able to produce Windows Runtime components (WinMD).
.NET Framework Team
This contradicts the information here: http://msdn.microsoft.com/library/windows/apps/jj714086(v=vs.105).aspx#BKMK_WhattoshareinaPortableClasslibrary
"Windows Runtime APIs aren’t portable and can’t be used in a Portable Class Library. There is overlap in the Windows Runtime APIs that are supported on Windows Phone 8 and Windows 8. However, binary compatibility is not supported. Your code has to be compiled for each platform and therefore isn’t suitable for a Portable Class Library. Here too you should abstract the use of Windows Runtime APIs into classes or objects that aren’t shared in a Portable Class Library."
Was just a subset of the WinRT APIs made available or has this not actually shipped yet?
David Kean commented
Thanks for the great feedback. We're considering this for a future version.
Jay Kannan commented
You can use PCLStorage library from nuget