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

解决方案 »

  1.   

    从托管应用程序调用非托管代码
    当调用用户定义的 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但愿有用!