Embedding the Ruby interpreter in C# app

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


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

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

– Nick

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs