[Ironruby-core] Accessing a Module's Classes from C# with dynamic

Tomas Matousek Tomas.Matousek at microsoft.com
Sat Jan 15 12:53:22 EST 2011

Another option would be 


I haven't tried that, but I think it should work. Neither solution is indeed ideal. CLR interop with Modules isn't quite polished yet.


-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Joshua M.
Sent: Friday, January 14, 2011 11:55 PM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Accessing a Module's Classes from C# with dynamic

It turns out that the problem is not accessing a module's class, but accessing the contents of a module in a require'd file.

  require 'app'

  module RbScriptApp
      class Foo
          def Bar()
              return (rand(100) + 1).to_s()

No matter what I do I can only access RbScriptApp and not Foo if I call Runtime.UseFile("global.rb"). So far I have two other work arounds: 1.) create wrapper methods for everything I want to access in app.rb (ugh), or 2.) use Engine.Execute("RbScriptApp::Foo.new"). The latter is more preferrable, I suppose, but it seems strange that I can't access Foo by dynamic.

Any more information about this issue would be very helpful and appreciated.

Posted via http://www.ruby-forum.com/.
Ironruby-core mailing list
Ironruby-core at rubyforge.org

More information about the Ironruby-core mailing list