[Ironruby-core] Casting Objects (COM Interop) addendum

Orion Edwards orion.edwards at gmail.com
Thu Mar 26 18:22:26 EDT 2009

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:

`ToType': invalid value for Class: ProxyLi
b::ICanDoStuff (ArgumentError)
        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>

More information about the Ironruby-core mailing list