Adding a "winmd" reference vs Adding a project reference
.net, c#, visual-studio, visual-studio-2012, windows-phone-8
Solution
Well I managed to make it work. As the stacktrace in the original post would suggest, I am using SQLite in my application. If I add the `winmd` file as a reference instead of the C++ project, it looks like some dependencies are not satisfied.
Therefore I had to add a reference to `SQLite for Windows Phone` into the `WP8ClassLibrary` project. That was somehow a dumb mistake of mine because this C++ project probably carried this dependency with itself (there are several `winmd` references in it but I could not guess they would be part of the `SQLite for Windows Phone` based on their obscure names).
Problem
I have a Windows Phone 8 project and another project written in C++ ; both are in the same solution. The C++ project is a dynamic library used in the WP8 project, and it is configured to produce a Windows Metada file (`.winmd`) on top of the `.dll` file. When adding the C++ project as a Project Reference in the WP8 project, everything works perfectly well. However, I'd like to reference directly the binaries instead of the project so I tried referencing the `.dll` itself but VS2012 would not let me (which I totally understand since the library is unmanaged from what I understand). Adding the `.winmd` file instead works, I mean it compiles without warning/errors ; but it crashes at runtime (I get a `TargetInvocationException` which is raised because the "actual" code of the C++ library cannot be found). When adding the `.winmd` file, I made sure the `.dll` file was next to it. Putting both the files in the `bin` directory of the WP8 project does not work either. I can't find any clues on the internet and I'd be grateful if you could give me some, any hints are welcome! Here is a schema of the trivial architecture I'm trying to set up: And here is the stacktrace of the exception raised: ``` at System.StubHelpers.StubHelpers.GetWinRTFactoryObject(IntPtr pCPCMD) at Sqlite.Sqlite3.sqlite3_open_v2(String filename, Database& db, Int32 flags, String zVfs) at SQLite.SQLite3.Open(String filename, Database& db, Int32 flags, IntPtr zVfs) at SQLite.SQLiteConnection..ctor(String databasePath, SQLiteOpenFlags openFlags, Boolean storeDateTimeAsTicks) at SQLite.SQLiteConnection..ctor(String databasePath, Boolean storeDateTimeAsTicks) at WP8ClassLibrary.SomeManager..ctor(String databasePath) at WP8App.SomeViewModel..ctor() at WP8App.MainPage..ctor() ```