查过一些资料
基本上可以调用函数象:
[DllImport ("ex.dll")]
public extern static int Set(int i);但是为什么运行的时候提示无法找到ex.dll中set的入口??还有就是如果我想调用ex.dll文件中的类应该怎么写?ex.dll文件包括:
Hello.h:class Hello{
private:
int _i;
public:
void Set(int i);
int Get();
};Hello.cpp:#include ".\hello.h"
void Hello::Set(int i){
this->_i = i;
}
int Hello::Get(){
return this->_i;
}

解决方案 »

  1.   

    参考VS自带的例子:
    C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Samples\Technologies\Interop\PlatformInvoke\Custom
      

  2.   

    http://www.microsoft.com/china/msdn/library/langtool/vcsharp/ousNET.mspx
      

  3.   

    对于无法找到 Set 函数的问题,请确认该 .DLL 文件是否有该函数,以及该函数名字是否正确。
      

  4.   

    编辑def文件,按如下方式写:
    EXPORT
      set 1@
      Dllmain 2@