Forum: IronRuby Casting Objects (COM Interop) addendum

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Orion E. (Guest)
on 2009-03-27 00:23
(Received via mailing list)
As a follow up to my last message, I wrote a small util method, as
follows:
public static class Util
{
  public static T Cast<T>(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:in
`ToTypes'
        from
c:\NB\DLR\18015\Languages\Ruby\Src\IronRuby.Libraries\Builtins\MethodOps.cs:75:in
`BindGenericParameters'
        from :0:in `of'
        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
Shri B. (Guest)
on 2009-03-27 00:29
(Received via mailing list)
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/idi...
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<T>(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:in
`ToTypes'
        from
c:\NB\DLR\18015\Languages\Ruby\Src\IronRuby.Libraries\Builtins\MethodOps.cs:75:in
`BindGenericParameters'
        from :0:in `of'
        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
This topic is locked and can not be replied to.