2009-10-31 55 views
0

这是我的代码错误在我的呼唤功能

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); 

这里我receving回调函数

static public void Callbackas(eNotificationType type, IntPtr datas) {} 

在这里第一次我receving数据的功能然后它给出错误消息,如:

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

这是你的代码,您所呼叫(对不起粗略搜索只能找到你的另一职务提到startVssSdkClientEcho)。是decalred的cdecl(即它根本没有__declspec)还是stdcall。如果是的cdecl您需要CallingConvention属性添加到的DllImport

 
[DllImport("VssSdkd", CallingConvention=CallingConvention.Cdecl)] 

当然这也可能是回调调用过错约定这是另一个问题。