How do I pass an ExpandoObject from C# into IronRuby?

I tried to send this question earlier, but it did not appear to go
through. Shortly after I tried to send it the first time, the “Consuming
DynamicObjects in IronRuby” thread popped up. It seems likely that the
two issues are related, but as my situation is a bit different and
results in a different error message, I thought it would be a good idea
to resend this question. Note: I am using .Net 4.0 RC and the “CTP for
.Net 4.0 RC” release of IronRuby…

So I’m finally getting around to testing IronRuby/C# integration and hit
a stumbling block. Let’s say I have the following class in Ruby:

class HandleMoveRequested

            def handle(msg)

                            System::Console.WriteLine "Moving 

character to " + msg.x.to_s + “,” + msg.y.to_s + “.”

            end

end

As you can see it is a simple message handler that expects an object
that has an “x” and a “y” property. Now say I have the following C#
code:

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

dynamic msg = new ExpandoObject();

msg.x = 1;

msg.y = 2;

handler.handle(msg);

Creating the handler instance works fine, so I won’t bore you with the
details of that, but for some reason the last line throws an
InvalidOperationException with the message “unbound variable: value”.
Everything works if the message is a Ruby class that I create manually,
but I’d love to be able to just create a fully dynamic object (such as
the ExpandoObject) here and pass it in. Is this just not possible?

Confidentiality Notice: This e-mail message, including any attachments,
is for the sole use of the intended recipient(s) and may contain
confidential and privileged information. Any unauthorized review, copy,
use, disclosure, or distribution is prohibited. If you are not the
intended recipient, please contact the sender by reply e-mail and
destroy all copies of the original message.

Answered your question over on StackOverflow:
http://stackoverflow.com/questions/2365668/how-do-i-pass-an-expandoobject-from-c-into-ironruby/

http://stackoverflow.com/questions/2365668/how-do-i-pass-an-expandoobject-from-c-into-ironruby/Essentially,
Tomas fixed this, and if you build from source now, your code will work.
Thanks
Best Regards,
Kevin R.

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