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()
winmd
andall
files are in the list displayed afterBegin Xap packaging
. I simplified a bit the situation in my original post ; I have a C++ file producing adll
and awinmd
, thiswinmd
is used in a WP8 class library project which produces adll
used in a "concrete" WP8 project. The twodll
and thewinmd
files are correctly copied during the build. – Narcoanalysis