Hi, I'm looking for some assistance in embedding the ruby interpreter
in C#. I've got well through the basics of using p/invoke to load the
C api methods, and I'm having some brain-destroying problems with
getting a ruby string back to a System.String for certain size
strings.

http://pastie.caboo.se/15227

The pastie has some snips of the code that I can reproduce the failure
with. It seems, that for arbitrarily large strings rb_string_to_cstr
fails. The value of i at which the code fails is not constant and
seems to be anywhere greater than 200. Occasionally, the code will run
through to completion.

I have no idea what I need to do here. I've tried some GCHandle
pinning of objects to no avail, but I'm pretty green at
.net/C#/dllimport/p|invoke.

Has anyone done this? Or something similar and can shed some light on
my problem?

-- Nick