简体   繁体   English

如何在Windows Phone 8(C#)框架中添加C ++ DLL

[英]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. 我试图在Visual Studio Express 2012中向Windows Phone 8框架添加C ++ DLL。

I have tried following ways 我试过以下方法

  1. Import and invoke through PInvoke 通过PInvoke导入和调用

    [DllImport("WP8DLL.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport(“WP8DLL.dll”,CallingConvention = CallingConvention.Cdecl)]

    public static extern int functionReturningInteger(); 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 . 结果:这种方式虽然没有编译错误,但是当我尝试访问DLL的方法时,它会抛出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 " 结果:我收到消息“无法将对更高版本或不兼容程序集的引用添加到项目中

You cannot add a reference from a Managed Windows Phone 8 Project directly to a native static or native dynamic library. 您无法将Managed Windows Phone 8 Project中的引用直接添加到本机静态或本机动态库。 You will need to create a Windows Phone Runtime Component. 您需要创建Windows Phone运行时组件。 Those can be referenced by you UI project and also it can reference C++ projects, etc. 这些可以由您的UI项目引用,也可以引用C ++项目等。

See for example this link for more information. 有关详细信息,请参阅此链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM