On Tue, 27 Jan 2004 16:29:46 -0800, [EMAIL PROTECTED] wrote: >// Callback function pointer def >typedef unsigned (__cdecl *ioCallbackPtr)(unsigned char *buffer, >unsigned long count, unsigned long filePtr); > <snip> >If the initial function expects the callback to be called with the cdecl >calling convention, can that be specified in the C# declaration for the >callback?
Be aware that CallingConvention enum used by the DllImport attribute only specifies the calling convention when calling from managed code to unmanaged code and not the other way around. Your callback function prototype indicates that the unmanaged code expects to call the calback function using CDECL. When you pass a callback function ptr via a Delegate to unmanaged code, the CLR *always* expects that function to be called using the stdcall calling convention. There is no attribute to modify this behavior. Hence I believe you will need to go the MC++ shim approach I mentioned before. BTW, you can try this without the shim and it might seem to work but just remember. In this scenario, both sides will clean up the stack and that will cause some weird behavior (most likely a crash). -- Keith =================================== This list is hosted by DevelopMentor® http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com