简体   繁体   中英

Error in my calling Function

this is my code

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

am call the function like

CallBack calbck = new CallBack(TestDllImport.Callbackas);

startVssSdkClientEcho("192.168.10.240", 12050, calbck, TestDllImport.eProtocolType.eProtocolType_VssSdk, false);

here my receving callback function is

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

here first time am receving data and then it's giving Error msg like :

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 

please help me to identify my error... thanks in advance

Is this your code you are calling (sorry cursory search could only find your other post referring to startVssSdkClientEcho). Is it decalred cdecl (ie it has no __declspec at all) or is it stdcall. If it is cdecl you need to add CallingConvention attribute to the DllImport

ie

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

Of course it might also be the callback calling convention at fault which is another issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM