2

执行下面的代码在最后一行给了我以下异常:

InvalidOperationException:“未绑定变量:值”

var rubyRuntime = Ruby.CreateRuntime();
rubyRuntime.UseFile("HandleMoveRequested.rb");
var engine = rubyRuntime.GetEngine("rb");
dynamic ruby = engine.Runtime.Globals;

var handler = ruby.HandleMoveRequested.@new();

dynamic msg = new ExpandoObject();
msg.x = 1;
msg.y = 2;

handler.handle(msg);

HandleMoveRequested.rb 的内容是:

class HandleMoveRequested
    def handle(msg)
        System::Console.WriteLine msg.x
        System::Console.WriteLine msg.y
    end
end

基本上我只是希望能够将一个完全动态的对象传递给该 Ruby 对象的“句柄”方法,并让它能够访问该对象的“x”和“y”属性。我在吠叫错误的树吗?

4

1 回答 1

1

在从源代码构建最新版本后,我测试了您的代码(原样):http: //github.com/ironruby/ironruby

请试试这个。我想修复将包含在下一个 RC 构建(RC3?)及更高版本中。
从源代码构建时,请确保使用 Ruby4.sln 构建“V4 Release”版本

编辑:我自己测试过,这在最新版本中没有问题

于 2010-03-03T18:33:36.223 回答