[Ironruby-core] StackOverflowException when accessing object properties

Andrew Peters andrew at mindscape.co.nz
Sat Nov 15 02:06:39 EST 2008


I think this is because you need to reference the IronRuby.Libraries dll.
Strange error I know.

On Sat, Nov 15, 2008 at 7:33 PM, Benjamin Van der veen <lists at ruby-forum.com
> wrote:

> Hello all,
>
> Why does the stack overflow?
>
> class Program
> {
>    static void Main(string[] args)
>    {
>        ScriptRuntime runtime = Ruby.CreateRuntime();
>        ScriptEngine engine = runtime.GetRubyEngine();
>
>        ScriptScope scope = engine.CreateScope();
>        scope.SetVariable("my_var", new TestClass() { Text = "Hello
> world!", Number = 42 });
>
>        ScriptSource source =
> engine.CreateScriptSourceFromString("my_var.text");
>        Console.WriteLine(source.Execute<object>(scope));
>    }
> }
>
> class TestClass
> {
>    public string Text;
>    public int Number;
> }
>
> If I set "my_var" to a string and query it's Length property, no
> problem. I'm sure I'm missing something—I came up with this code by
> reading a PDF found on the IronRuby site
> (http://ironruby.net/@api/deki/files/1/=dlr-spec-hosting.pdf --
> redirects to Amazon S3) because I couldn't find any examples. Maybe I
> need to somehow import TestClass' namespace into the scope?
>
> Thanks a lot, and apologies in advance for formatting problems (can't
> find a preview post option).
>
> benjamin
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20081115/8d5990b1/attachment.html>


More information about the Ironruby-core mailing list