Orion Edwards
2009-Mar-26 22:22 UTC
[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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090327/3a0aa742/attachment.html>
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: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Orion Edwards Sent: Thursday, March 26, 2009 3:22 PM To: ironruby-core at rubyforge.org 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090326/39045066/attachment.html>