Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a C++ DLL in Windows Phone 8 (C#) Framework

I am trying to add a C++ DLL to Windows Phone 8 framework in Visual Studio Express 2012.

I have tried following ways

  1. 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.

  2. 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"

like image 795
DeveloperLove Avatar asked Nov 20 '12 13:11

DeveloperLove


1 Answers

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.

like image 100
vidstige Avatar answered Nov 09 '22 19:11

vidstige