Nastya Kholodova
Nastya Kholodova

Reputation: 1321

What are the biggest challenges when making library WinRT compatible?

I have a dll with core functionality which I wan't to use at ASP.MVC application and Metro app. So I made Portable Library compatible with .NET 4.0 and .NET for Widows store app from my dll. As expected build was failed. The main reasons was:

  1. Serializable attribute http://social.msdn.microsoft.com/Forums/en/winappswithcsharp/thread/b2ca4ac8-326d-48b0-bb45-965459a99808 - painful surprise
  2. System.Reflection.Emit namespace http://geekswithblogs.net/mbrit/archive/2012/06/05/say-goodbye-to-system.reflection.emit-any-dynamic-proxy-generation-in-winrt.aspx
  3. Usages of FileInfo class. Pretty much expected that all file system calls won't be working

I know that all UI classes won't be compiled, also.

So my question is What namespaces and classes do I have to avoid if I what to share my library between .net 4.0 and WinRT?

UPDATE Here is full list of changes in classes and namespaces http://msdn.microsoft.com/en-us/library/windows/apps/br230302%28v=vs.110%29.aspx#convert

Upvotes: 1

Views: 372

Answers (1)

Damir Arh
Damir Arh

Reputation: 17855

If you're writing new code that you want to reuse in .NET framework and Windows Store apps, it's best that you immediately start writing your code as a portable class library with these two target platforms selected. This way you'll only have available the classes and methods that work on both platforms (Intellisense works as expected as well).

You can find an overview of the available APIs for each of the supported platforms here.

For the APIs that are not supported through portable class libraries because they are conceptually different but are still available in a way (file IO is a good example) you can use the abstraction/indirection pattern to implement them differently for each of the platforms. Here's a good explanation of this approach.

Upvotes: 2

Related Questions