WP Runtime Component - Type load exception?

c#, visual-studio-2012, windows-phone, windows-phone-8, windows-runtime

Solution

The reason was quite simple in my case: the .winmd file and the .dll file generated from the WinRT Component must have THE SAME NAME (e.g: testRT.dll and testRT.winmd).

Then:

- Add the .winmd medata file as a reference in your project.

- Check that the .winmd / dll files are in the same folder to be correctly loaded.

Problem

What works > Library setup I have a Windows Phone 8 solution with 2 projects: - "Hello", a simple library project -> generates Hello.dll. - "HelloNativeRT", a WP Runtime Component with C++ files -> generates HelloNativeRT.dll and HelloNativeRT.winmd In this solution, the "Hello" library references the WP Runtime Component, so calls like... ``` HelloNativeRT.SampleNamespace test = new HelloNativeRT.SampleNamespace(); ``` ...work fine in this library project. What doesn't work > WP8 app setup However, I want to use these two libraries in a Windows Phone 8 app, but without adding references to the projects, since I need to ship the compiled libraries to clients. - I referenced the Hello.dll file in the project, as well as the HelloNativeRT.winmd file. - When I launch the application in debug mode, and goes to the line `HelloNativeRT.SampleNamespace test = new HelloNative...` it crashes and says "TypeLoadException", like it cannot load the native module. I suppose I need to include the HelloNativeRT.dll file in a way or another, since I guess it contains the native (compiled) code, as the winmd file may only embed the C++/CX code. How should I setup my project to include this DLL? I tried to put it at the root of the WP8 project, to reference it, to embed it... with no luck.

Original source