locked
Wrap a .Net library in a Windows Runtime Component

    Question

  • In my earlier question, Rob (MSFT) mentioned that a .NET library could be wrapped in a Windows run time component. I am looking for any tutorials or samples on how to do it. I have seen many samples on how to creating a windows run time component from scratch but haven't found anything that is used to wrap an existing .NET library. I will appreciate if anyone can provide any help on how to do it.

    Thursday, February 20, 2014 3:41 PM

Answers

  • See the Creating Windows Runtime Components in C# and Visual Basic docs. The first section is on types.

    You can use any valid .Net types inside the component. Anything passed in or out must be representanle by runtime classes. Give the docs a read and come back with any more specific questions you have.

    --Rob

    • Marked as answer by Kam2011 Thursday, February 20, 2014 4:40 PM
    Thursday, February 20, 2014 4:33 PM
    Owner

All replies

  • You would create your Windows Runtime Component, define the classes and methods you want to expose, and call your existing library from those classes and methods.

    --Rob

    Thursday, February 20, 2014 4:10 PM
    Owner
  • Are there any articles or samples specially that requires any data types marshaling? I am basically trying to learn what data types can easily be used between .net and WinRT ( probably all primitives like int, strings??) while what are the options for any data types that cannot be used directly between .NET and WinRT  but can some how could be transformed from .net into WinRT component

    • Edited by Kam2011 Thursday, February 20, 2014 4:31 PM clarified
    Thursday, February 20, 2014 4:13 PM
  • See the Creating Windows Runtime Components in C# and Visual Basic docs. The first section is on types.

    You can use any valid .Net types inside the component. Anything passed in or out must be representanle by runtime classes. Give the docs a read and come back with any more specific questions you have.

    --Rob

    • Marked as answer by Kam2011 Thursday, February 20, 2014 4:40 PM
    Thursday, February 20, 2014 4:33 PM
    Owner
  • Exactly what I was looking for as a starting point. I will go over it and comeback if there are any questions.
    Thursday, February 20, 2014 4:40 PM
  • Rob,

    Regarding you statement "call your existing library from those classes and methods" is that in order to do so, I first need to add a project reference in my WinRT component and Visual studio does not allow it? So when you said You can wrap a .Net library in a Windows Runtime Component and call it from a JavaScript app in question here does that apply to a regular CLR/.net library developed in C#?

    Thanks

    Sunday, February 23, 2014 5:02 PM
  • The library must be valid for Windows Store apps. It must be built on the .Net Framework for Windows Store apps or as  Portable Class Library. Classes such as System.Drawing which are not valid in Windows Store apps are still not valid in Windows Store apps.

    Sunday, February 23, 2014 5:32 PM
    Owner