这是我的代码
public delegate void NotifyFunc(enumType notificationType, IntPtr data);
[DllImport("VssSdkd")]
public static extern void startVssSdkClientEcho(string IpAddress,
long port, NotifyFunc notifyFunc, eProtocolType proType, bool Req);
调用函数
CallBack calbck = new CallBack(TestDllImport.Callbackas);
startVssSdkClientEcho("192.168.10.240", 12050, calbck, TestDllImport.eProtocolType.eProtocolType_VssSdk, false);
这里我的接收回调函数是
static public void Callbackas(eNotificationType type, IntPtr datas) {}
这是第一次接收数据,然后它给出错误消息,如:
run time check failure #0 - the value if ESP was not properly saved across a function call.
this is usually a result of calling a function declared with one calling convention
with a function pointer declared with a different calling convention
请帮我识别我的错误...提前谢谢
答案 0 :(得分:0)
这是您正在调用的代码(抱歉粗略搜索只能找到您的其他帖子引用startVssSdkClientEcho)。是decalred cdecl(即它根本没有__declspec)还是stdcall。如果是cdecl,则需要将CallingConvention属性添加到DllImport
即
[DllImport("VssSdkd", CallingConvention=CallingConvention.Cdecl)]
当然它也可能是错误的回调调用约定,这是另一个问题。