In article <006701c35b43$73141be0$0207a8c0@mascarenhas>, Fabio Mascarenhas wrote: > Check calling conventions. Windows .NET uses STDCALL while the default for > the C compiler is CDECL, this messes things up when a C function calls a > .NET function (and make sure you're setting the CallingConvention attribute > of P/Invoked functions, too). I had the exact same problem writing a binding > from .NET to Lua. :-) > > The problem goes away with Rotor (the shared source CLR) on FreeBSD... the > default there is CDECL. Why Microsoft didn't use this more sensible default > for the Windows .NET is beyond me. [...] Wow! Thank you thank you thank you! That was the problem. I haven't done much C programming on Windows, so I didn't even know about these different calling conventions.