Goode, Troy
2010-Mar-03 07:14 UTC
[Ironruby-core] 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. at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/ironruby-core/attachments/20100303/8a372cef/attachment.html>
Kevin Radcliffe
2010-Mar-03 18:58 UTC
[Ironruby-core] How do I pass an ExpandoObject from C# into IronRuby?
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 Radcliffe On Wed, Mar 3, 2010 at 12:14 AM, Goode, Troy <Troy.Goode at nreca.coop> wrote:> 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. at 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. > _______________________________________________ > 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/20100303/35b5f498/attachment.html>