1、生成dll 导出方式为 I extern "C"
#define MY_API extern "C" __declspec(dllexport)
默认编译调用约定为 cdecl
2、C#代码加载dll,注意调用约定 CallingConvention.Cdecl
class MYDLL
{
// 注意调用约定,按MyDLL.dll修改!
[DllImport("MYDLL2.dll",EntryPoint = "SetBuffer", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.FastCall)]
public static extern int GetBuffer(byte[] data);
[DllImport("MYDLL.dll", EntryPoint = "GetValue", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetValue();
}