Search code examples
c#windows-runtimesoapocodto

What is the best way to reuse DTOs in WinRT


I am trying to create a class library of DTOs to be shared between my backend services which will be written in .NET 4.5, and a WinRT (StoreApp) front end.

I'm finding out that I can't simply reference the DTOs from the server side and front end projects at the same time. I know I can serialize and then deserialize the DTOs into a different type, but I still need to write the DTOs twice which I'm trying very hard to avoid.

I find it very frustrating that I can't reference a library of POCO classes from WinRT - which should not break any security abstraction. I hope it's just my omission and not by design.

So what is the best way to reuse boiler plate code meant for win store with its server side counter part?


Solution

  • There are two typical methods of sharing code between projects targeting different platforms/frameworks..

    You can either leverage Portable Class Libraries or use linked files which you can have shared between your different platform projects.