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.

Fabio Mascarenhas
mascarenhas / acm.org

----- Original Message ----- 
From: "Tim Sutherland" <timsuth / ihug.co.nz>
Newsgroups: comp.lang.ruby
To: "ruby-talk ML" <ruby-talk / ruby-lang.org>
Sent: Tuesday, August 05, 2003 2:58 AM
Subject: Re: Advocacy: Ruby on/with .net


> In article <slrnbihkb2.1bv.timsuth / alien.zone>, Tim Sutherland wrote:
> [...]
> > Yes, that is how I am doing it. NB: I'm planning to make the first
> > 'real' release of my rubydotnetproxy library by the upcoming Monday.
> [...]
>
> Monday has passed and I haven't released...I've been battling one bug
> for a number of days - when I call one C# method, bad stuff appears to be
> happening with the stack pointer. Hopefully it's just a bug somewhere in
my C
> code which can easily be fixed once found.