I am trying to add a C++ DLL to Windows Phone 8
framework in Visual Studio Express 2012.
I have tried following ways
Import and invoke through PInvoke
[DllImport("WP8DLL.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int functionReturningInteger();
Result: This way though there were no compile errors, but when I try to access the method of the DLL it throws System.NotSupportedException
.
Adding reference in the project properties
Result: I get the message "A reference to a higher version or incompatible assembly cannot be added to the project"
You cannot add a reference from a Managed Windows Phone 8 Project directly to a native static or native dynamic library. You will need to create a Windows Phone Runtime Component. Those can be referenced by you UI project and also it can reference C++ projects, etc.
See for example this link for more information.