Forum: IronRuby IronRuby & DynamicObject.TryGetMember returning null

3f0395d60ff60367915cdef62c38c7eb?d=identicon&s=25 Benjamin Joldersma (bennidhamma)
on 2011-09-09 08:45
I am working with IronRuby and a DynamicObject derived class to create a
proxy layer for a game scripting engine that allows me to intercept gets
and sets and do things like mark objects for saving, potentially
security checks, etc.

But I'm finding that if my TryGetMember returns true, but sets the out
result param to null, then IronRuby seems to hang indefinitely.

I've created a pretty concise repro case here:

can anyone shed some insight into this problem?  So far, I'm loving


--ben joldersma
3f0395d60ff60367915cdef62c38c7eb?d=identicon&s=25 Benjamin Joldersma (bennidhamma)
on 2011-09-09 09:03
Heads up, looks like this applies to the Expando object as well, here's
an even simpler gist:
959b1c9d700abfc065f5f40bf5a966a2?d=identicon&s=25 James Schementi (jschementi)
on 2011-09-09 11:13
(Received via mailing list)
Try implementing TryInvokeMember.

In IronRuby "" actually gets and invokes "foo", so it will use
DynamicObject's TryInvokeMember. This is different from IronPython and
C# where method calls are two operations: TryGetMember (d.Foo) and
TryInvoke (d.Foo()). The rough IronRuby equivalent to this is

3f0395d60ff60367915cdef62c38c7eb?d=identicon&s=25 Benjamin Joldersma (bennidhamma)
on 2011-09-10 02:44
Okay, very interesting stuff.  I had seen you and others suggest that in
other places, but I thought I was insulated from it, because I *was*
implementing TryInvokeMember!  After further examination, I seem to have
stumbled to a solution.

In my actual code, I was trying to return a function delegate in the
TryGetMember, when the member in question is a method.  I think that
this, coupled with the TryInvokeMember implementation was causing some
badness.  So I removed the delegate creation code in TryGetMember, and
just handle properties, and then in TryInvokeMember, I handle both
methods and properties (this seems to work!)

Thanks a million for your help!

Next problem: I'm hesitant to bring it up again, maybe I should be able
to figure this out on my own, but it's stumped me for quite a spell now.
I'm getting a System.InvalidOperationException that says "No coercion
operator is defined between types 'System.String' and
'IronRuby.Builtins.MutableString'" when I try and call a method on one
of my dynamic objects with a literal Ruby string.

I've created another gist that reproduces the problem here:

If I write 'test'.to_clr_string, this works, but that seems like kind of
a pain to have to do in my scripts...

Any ideas about this?  The difficult part about it is that it doesn't
even seem the runtime even gets to the point where any of my overrides
are executed - no breakpoints are hit in MonoDevelop, no console output,
so I don't think I can fix it from that vantage point...  Any help is
much appreciated.


This topic is locked and can not be replied to.