[Mono-list] Mono/.NET delegate incompatibility

Tum tum@veridicus.com
Thu, 19 Dec 2002 12:43:57 +1300


I guess the default calling convention in mono is cdecl.  According to
MSDN, the default calling convention for dllimport should be stdcall
(which IMHO really only makes sense on windows).

You could try setting the CallingConvention property on the DllImport to
cdecl.

e.g.

[DllImport("mydll.dll", CallingConvention=CallingConvention.Cdecl)]
public static extern void myfunc(int x);

^Tum

> -----Original Message-----
> From: mono-list-admin@ximian.com [mailto:mono-list-admin@ximian.com]
On
> Behalf Of J. Perkins
> Sent: Thursday, 19 December 2002 9:24 a.m.
> To: Mono-L
> Subject: [Mono-list] Mono/.NET delegate incompatibility
> 
> I am using a delegate to pass a function pointer into a unmanaged DLL.
> Under Linux/Mono everything works fine. Under Windows/.NET, my
callback
> function signature must look like this:
> 
>   void (__stdcall *func)(int);
> 
> But Windows/Mono seems to want:
> 
>   void (*func)(int);
> 
> Changing the signature will cause the other CLR to corrupt the stack.
> 
> Jason
> 379
> 
> 
> 
> 
> 
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list@ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list