C#中:
[DllImport(@"E:\code\SerailVcDll\Release\SerailVcDll.dll", EntryPoint="test", CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
public static extern int test(int a);vc++中:
int CSerailVcDllApp::test(int a)
{
return a;
}

解决方案 »

  1.   

    vc++ 中引出函数不是标准命名,你使用depends.exe察看一下你的dll的引出函数是什么?
      

  2.   

    用depends.exe查看了一下,引出函数是test。
      

  3.   

    dll路径是否正确,函数参数是否正确
      

  4.   

    只有在.def文件中有EXPORTS的才可以找到入口,例如:; FileZip.def : Declares the module parameters for the DLL.LIBRARY      "FileZip"
    DESCRIPTION  'FileZip Windows Dynamic Link Library'EXPORTS
        ; Explicit exports can go here
        AddFileToZip   @1  
        AddStreamToZip @2
      

  5.   

    从托管应用程序调用非托管代码
    当调用用户定义的 DLL 中所包含的函数时,有必要将 extern "C" 添加在 DLL 函数声明之前,如下所示:
    The function declaration in SampleDLL.h file
    extern "C" SAMPLEDLL_API int fnSampleDLL(void);详见http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/vccore/html/vcwlksysimportattributetutorial.asp但愿有用!
      

  6.   

    dumpbin /exports SerailVcDll.dll 
    能看到导出函数名吗?