2009-10-31 8 views
0

ceci est mon codeErreur dans mon appel Fonction

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 appeler la fonction comme

CallBack calbck = new CallBack(TestDllImport.Callbackas); 

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

ici ma fonction de rappel receving est

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

ici première fois am receving données et puis il donne erreur msg comme:

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 

s'il vous plaît me aider à identifier mon erreur ... merci à l'avance

Répondre

0

Est-ce votre code que vous appelez (recherche rapide désolé ne pouvait trouver votre autre poste faisant référence à startVssSdkClientEcho). Est-il decalred cdecl (c'est-à-dire qu'il n'a pas de __declspec du tout) ou est-ce stdcall? S'il est cdecl vous devez ajouter attribut CallingConvention au DllImport

à savoir

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

Bien sûr, il pourrait également être la convention d'appel rappel à la faute qui est une autre question.