如何从项目调用
这不是“如何从C#调用C ++函数”的重复
我知道如何为普通的PC应用程序做这个,我试过它的工作原理:
这称为P / Invoke
1. Create a C++ dll project, but you can't add the C++ dll project as a reference to the C# project. Copy the dll from C++, and paste the dll to the C# exe folder 2. in C# use [DllImport...] in C++ use extern "C" __declspec(dllexport) ...
但是当我在WindowsPhone上执行此操作时,失败了。
Windows Phone有2种类型的非托管c ++原生dll项目,我试过了
DLL (Windows Phone) <- WRT DLL 8.1 DLL (Windows Phone Silverlight 8.1)
我不知道在哪里放置dll文件。 因为finally exe是一个包。 我不能将dll放在与包相同的文件夹中。 dll应该在包中,作为包的一部分。
所以我尝试将dll添加为C#WP8.1 SL项目中的resorce文件。
但是函数调用失败了。
所以我想知道的是,如何放置dll,如何使用WP8.1 SL项目连接dll?
之前有没有尝试过?
谢谢你们的回答。
// ———————————————— ————
所以正确的方法是对于[C#WP8.1 SL]项目,我需要
create a [C++ Runtime Component DLL] <- as bridge create a [C++ Native WP SL DLL] <- real dll Add the [C++ Runtime Component DLL] as a reference to [C# WP8.1 SL] And the [C++ Native WP SL DLL] as a reference to [C++ Runtime Component DLL]
托管Windows Phone项目中无法引用非托管程序集。 在解决方案中创建Windows运行时组件,作为dll的包装器。 您可以将其他非托管dll链接到运行时组件。
请阅读以下链接了解更多详情:
创建Windows运行时组件
如何在Windows Phone项目中导入C ++ DLL
从Windows Phone Store应用程序中使用C ++库项目
Windows运行时组件样本-WP8.0