执行下面的代码在最后一行给了我以下异常:
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”属性。我在吠叫错误的树吗?