2
執行下面的代碼,讓我在最後一行以下異常:如何將C#中的ExpandoObject傳遞給IronRuby?
InvalidOperationException異常: 「綁定變量:值」
var rubyRuntime = Ruby.CreateRuntime();
rubyRuntime.UseFile("HandleMoveRequested.rb");
var engine = rubyRuntime.GetEngine("rb");
dynamic ruby = engine.Runtime.Globals;
var handler = [email protected]();
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」屬性那個對象。我吠叫錯了樹嗎?