Casting Objects (COM Interop) addendum


#1

As a follow up to my last message, I wrote a small util method, as
follows:
public static class Util
{
public static T Cast(object o)
{
return (T)o;
}
}

And then try to call it from ruby:

x = Util.method(:cast).of(ICanDoStuff).call(mycomobject)

However, the Util.method(:cast).of(ICanDoStuff) fails with this error:

c:\NB\DLR\18015\Languages\Ruby\Src\IronRuby.Libraries\Protocols.cs:405:in
ToType': invalid value for Class: ProxyLi b::ICanDoStuff (ArgumentError) from c:\NB\DLR\18015\Languages\Ruby\Src\IronRuby.Libraries\Protocols.cs:386:inToTypes’
from
c:\NB\DLR\18015\Languages\Ruby\Src\IronRuby.Libraries\Builtins\MethodOps.cs:75:in
BindGenericParameters' from :0:inof’
from :0

Util.method(:cast).of(String) works fine however - is this because I’m
trying to pass in a .NET interface (which lives in an auto-generated
interop
dll built by tlbimp) rather than a class?

Any help is much appreciated


#2

COM Interop is not supported in IronRuby. COM objects are not easily
reflectable. It can be supported. See
http://blogs.msdn.com/shrib/archive/2008/07/30/idispatch-support-on-in-ironpython-beta-4.aspx
for how IronPython does it. However, IronRuby has not done the
equivalent work yet. We will get to it at some point, but as noted in
http://www.ironruby.net/About/Roadmap, its low priority for now as there
are more important scenarios we need to nail first.

From: removed_email_address@domain.invalid
[mailto:removed_email_address@domain.invalid] On Behalf Of Orion E.
Sent: Thursday, March 26, 2009 3:22 PM
To: removed_email_address@domain.invalid
Subject: [Ironruby-core] Casting Objects (COM Interop) addendum

As a follow up to my last message, I wrote a small util method, as
follows:

public static class Util
{
public static T Cast(object o)
{
return (T)o;
}
}

And then try to call it from ruby:

x = Util.method(:cast).of(ICanDoStuff).call(mycomobject)

However, the Util.method(:cast).of(ICanDoStuff) fails with this error:

c:\NB\DLR\18015\Languages\Ruby\Src\IronRuby.Libraries\Protocols.cs:405:in
ToType': invalid value for Class: ProxyLi b::ICanDoStuff (ArgumentError) from c:\NB\DLR\18015\Languages\Ruby\Src\IronRuby.Libraries\Protocols.cs:386:inToTypes’
from
c:\NB\DLR\18015\Languages\Ruby\Src\IronRuby.Libraries\Builtins\MethodOps.cs:75:in
BindGenericParameters' from :0:inof’
from :0

Util.method(:cast).of(String) works fine however - is this because I’m
trying to pass in a .NET interface (which lives in an auto-generated
interop dll built by tlbimp) rather than a class?

Any help is much appreciated