我用c++写的一个a.dll,其中:
int foo()
{
int a;
......
return a;
}
为什么用C#如下调用时候出错?
[DllImport("a.dll",EntryPoint="foo")]
extern static int foo();
......
int ret = foo();
运行时候抛出无法找到入口函数foo的错误。
请问应该如何修改?其中a.dll放在/Winnt/System32目录下。
...全文
4621打赏收藏
C#如何调用C++写的传统dll中的函数?
我用c++写的一个a.dll,其中: int foo() { int a; ...... return a; } 为什么用C#如下调用时候出错? [DllImport("a.dll",EntryPoint="foo")] extern static int foo(); ...... int ret = foo(); 运行时候抛出无法找到入口函数foo的错误。 请问应该如何修改?其中a.dll放在/Winnt/System32目录下。
你用dll模板创建时,并没有.def文件,因为把定义供其它语言的程序使用,这一点,你可在老的msdn中查到,原话为:
EXPORTS definitions
This statement makes one or more definitions available as exports to other programs