2009-10-31 34 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)] 

當然這也可能是回調調用過錯約定這是另一個問題。