Search code examples
c#c++windows-phone-8class-library

How can Windows Runtime Component written in C++ be referenced from Class Library written in C#?


I am working on WP8 project that includes class library project as C# source code and Windows Runtime Component as C++ source code. Does anyone know whether or not it is possible to create such C# class library which would reference Windows Runtime Component? The ultimate result should be .NET assembly and .WIMND/.DLL runtime component that can be used for application. Currently I cannot build class library because it doesn't see Windows Runtime Component, even though I added it to the project.

More specific. I have, say, MyNs.MyClass.MyMethod() which is defined in C++ runtime component and used from C# class library. Currently I cannot compile C# due to missing method although I have windows runtime component project attached to the same solution.


Solution

  • I solved this by adding reference to Windows runtime component manually into the C# class library .csproj file as follows

    ...
        <ItemGroup>
            <Reference Include="WindowsRuntimeComponent.winmd" />
        </ItemGroup>
    ...