# Accessing classes defined in IronRuby.dll from within IronRuby (IronRuby 1.0RC1)

**URL:** <https://www.ruby-forum.com/t/accessing-classes-defined-in-ironruby-dll-from-within-ironruby-ironruby-1-0rc1/181772>\
**Category:** IronRuby\
**Created:** [January 18, 2010, 3:45am UTC](https://www.ruby-forum.com/t/accessing-classes-defined-in-ironruby-dll-from-within-ironruby-ironruby-1-0rc1/181772 "2010-01-18T03:45:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Orion\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/65b543/32.png) [@Orion\_E](https://www.ruby-forum.com/u/Orion_E)\
**Post date:** [January 18, 2010, 3:45am UTC](https://www.ruby-forum.com/t/accessing-classes-defined-in-ironruby-dll-from-within-ironruby-ironruby-1-0rc1/181772/1 "2010-01-18T03:45:26Z")

</div>

I’d like to use the IronRuby name mangling methods from within a script  
I’m  
writing, but it seems as though I can’t access things that are defined  
in  
IronRuby.dll?

Reflector tells me that TryMangleName is a public static method  
on IronRuby.Runtime.RubyUtils, which is defined in IronRuby.dll.

I’m trying to access it like this:

> load\_assembly ‘IronRuby’  
> =\> true  
> System::AppDomain.current\_domain.get\_assemblies.each{|x| puts x}; nil  
> …(snip) …  
> System, Version=2.0.0.0, Culture=neutral,  
> PublicKeyToken=b77a5c561934e089  
> IronRuby, Version=0.9.3.0, Culture=neutral,  
> PublicKeyToken=31bf3856ad364e35  
> Microsoft.Scripting, Version=0.9.6.20, Culture=neutral,  
> PublicKeyToken=31bf3856ad364e35  
> …(snip) …  
> =\> nil  
> IronRuby::Runtime::RubyUtils.try\_mangle\_name(“Foo”)  
> NameError: uninitialized constant IronRuby::Runtime  
> IronRuby::Runtime  
> NameError: uninitialized constant IronRuby::Runtime

Is IronRuby treating it’s own dll’s specially? If so, is there any way I  
can  
get at the name mangling function?

Thanks, Orion.

---

<div class="post-metadata">

**Author:** ![Orion\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/65b543/32.png) [@Orion\_E](https://www.ruby-forum.com/u/Orion_E)\
**Post date:** [January 18, 2010, 3:57am UTC](https://www.ruby-forum.com/t/accessing-classes-defined-in-ironruby-dll-from-within-ironruby-ironruby-1-0rc1/181772/2 "2010-01-18T03:57:08Z")

</div>

load\_assembly ‘IronRuby’ will do the trick.

Doing require ‘ironruby’ will actually load the ironruby.rb in the  
ironruby library dir, but that file just warns that its not required to  
load that file, and doesn’t load any assemblies. We should probably just  
get rid of that file, or make it actually load the assembly.

~Jimmy

On Jan 17, 2010, at 6:45 PM, “Orion E.”  
\<[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

I’d like to use the IronRuby name mangling methods from within a script  
I’m writing, but it seems as though I can’t access things that are  
defined in IronRuby.dll?

Reflector tells me that TryMangleName is a public static method on  
IronRuby.Runtime.RubyUtils, which is defined in IronRuby.dll.

I’m trying to access it like this:

> load\_assembly ‘IronRuby’  
> =\> true  
> System::AppDomain.current\_domain.get\_assemblies.each{|x| puts x}; nil  
> …(snip) …  
> System, Version=2.0.0.0, Culture=neutral,  
> PublicKeyToken=b77a5c561934e089  
> IronRuby, Version=0.9.3.0, Culture=neutral,  
> PublicKeyToken=31bf3856ad364e35  
> Microsoft.Scripting, Version=0.9.6.20, Culture=neutral,  
> PublicKeyToken=31bf3856ad364e35  
> …(snip) …  
> =\> nil  
> IronRuby::Runtime::RubyUtils.try\_mangle\_name(“Foo”)  
> NameError: uninitialized constant IronRuby::Runtime  
> IronRuby::Runtime  
> NameError: uninitialized constant IronRuby::Runtime

Is IronRuby treating it’s own dll’s specially? If so, is there any way I  
can get at the name mangling function?

Thanks, Orion.

* * *

Ironruby-core mailing list  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

---

<div class="post-metadata">

**Author:** ![Orion\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/65b543/32.png) [@Orion\_E](https://www.ruby-forum.com/u/Orion_E)\
**Post date:** [January 18, 2010, 5:35am UTC](https://www.ruby-forum.com/t/accessing-classes-defined-in-ironruby-dll-from-within-ironruby-ironruby-1-0rc1/181772/3 "2010-01-18T05:35:29Z")

</div>

I am doing load\_assembly ‘IronRuby’, and it didn’t work (the example is  
copy/pasted pretty much verbatim). Not sure if that means your version  
of IR  
is different to mine, or what?

Cheers,

On Mon, Jan 18, 2010 at 3:56 PM, Jimmy S. \<

---

<div class="post-metadata">

**Author:** ![Orion\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/65b543/32.png) [@Orion\_E](https://www.ruby-forum.com/u/Orion_E)\
**Post date:** [January 18, 2010, 7:24am UTC](https://www.ruby-forum.com/t/accessing-classes-defined-in-ironruby-dll-from-within-ironruby-ironruby-1-0rc1/181772/4 "2010-01-18T07:24:20Z")

</div>

IronRuby is a module already defined in standard library. It gives you  
access to a bunch of useful APIs, including name mangling:

> > > IronRuby.singleton\_methods  
> > > =\> [“configuration”, “globals”, “load”, “loaded\_assemblies”,  
> > > “loaded\_scripts”, “require”, ‘create\_runtime’, ‘create\_engine’,  
> > > ‘create\_ruby\_setup’, ‘get\_engine’, ‘require\_file’,  
> > > ‘get\_execution\_context’]  
> > > IronRuby.constants  
> > > =\> [“Clr”, “Print”]  
> > > IronRuby::Clr.constants  
> > > =\> [“BigInteger”, “FlagEnumeration”, “Float”, “Integer”,  
> > > “MultiDimensionalArray”, “String”, “Name”, “Scope”]  
> > > IronRuby::Clr::Name.singleton\_methods(false)  
> > > =\> [“clr\_to\_ruby”, “mangle”, “ruby\_to\_clr”, “unmangle”]  
> > > include IronRuby::Clr  
> > > Name.mangle(“FooBar”)  
> > > =\> “foo\_bar”  
> > > Name.unmangle(“my\_foo”)  
> > > =\> “MyFoo”

Re loading IronRuby.dll - the problem is that IronRuby is also a  
namespace in IronRuby.dll so there is a name conflict we don’t probably  
handle the best we could. Loading IronRuby.dll shouldn’t be a common  
scenario though. The best place for IronRuby specific functionality is  
in the IronRuby module. If you’re missing some let us know.

Tomas

From: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Orion E.  
Sent: Sunday, January 17, 2010 8:29 PM  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] Accessing classes defined in IronRuby.dll  
from within IronRuby (IronRuby 1.0RC1)

I am doing load\_assembly ‘IronRuby’, and it didn’t work (the example is  
copy/pasted pretty much verbatim). Not sure if that means your version  
of IR is different to mine, or what?

Cheers,  
On Mon, Jan 18, 2010 at 3:56 PM, Jimmy S.  
\<[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:  
load\_assembly ‘IronRuby’ will do the trick.

---

<div class="post-metadata">

**Author:** ![Orion\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/65b543/32.png) [@Orion\_E](https://www.ruby-forum.com/u/Orion_E)\
**Post date:** [January 18, 2010, 9:46pm UTC](https://www.ruby-forum.com/t/accessing-classes-defined-in-ironruby-dll-from-within-ironruby-ironruby-1-0rc1/181772/5 "2010-01-18T21:46:32Z")

</div>

Thanks for that Tomas.

I ended up copy/pasting the String#camelize and #underscore methods from  
rails as they were only a couple of lines long. This is probably less  
error  
prone than importing types from the IronRuby dll in the long run anyway  
🙂

Cheers.

On Mon, Jan 18, 2010 at 7:35 PM, Tomas M. \<

---

<div class="post-metadata">

**Author:** ![Orion\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/65b543/32.png) [@Orion\_E](https://www.ruby-forum.com/u/Orion_E)\
**Post date:** [January 18, 2010, 7:36am UTC](https://www.ruby-forum.com/t/accessing-classes-defined-in-ironruby-dll-from-within-ironruby-ironruby-1-0rc1/181772/6 "2010-01-18T07:36:03Z")

</div>

BTW, if you really needed to get to IronRuby.dll’s types you can use  
this workaround:

> > > Utils = System::Type.get\_type(‘IronRuby.Runtime.RubyUtils, IronRuby’).to\_class  
> > > =\> IronRuby::Runtime::RubyUtils  
> > > Utils.try\_unmangle\_name(“foo\_bar”)  
> > > =\> ‘FooBar’

Tomas

From: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Tomas M.  
Sent: Sunday, January 17, 2010 10:24 PM  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] Accessing classes defined in IronRuby.dll  
from within IronRuby (IronRuby 1.0RC1)

IronRuby is a module already defined in standard library. It gives you  
access to a bunch of useful APIs, including name mangling:

> > > IronRuby.singleton\_methods  
> > > =\> [“configuration”, “globals”, “load”, “loaded\_assemblies”,  
> > > “loaded\_scripts”, “require”, ‘create\_runtime’, ‘create\_engine’,  
> > > ‘create\_ruby\_setup’, ‘get\_engine’, ‘require\_file’,  
> > > ‘get\_execution\_context’]  
> > > IronRuby.constants  
> > > =\> [“Clr”, “Print”]  
> > > IronRuby::Clr.constants  
> > > =\> [“BigInteger”, “FlagEnumeration”, “Float”, “Integer”,  
> > > “MultiDimensionalArray”, “String”, “Name”, “Scope”]  
> > > IronRuby::Clr::Name.singleton\_methods(false)  
> > > =\> [“clr\_to\_ruby”, “mangle”, “ruby\_to\_clr”, “unmangle”]  
> > > include IronRuby::Clr  
> > > Name.mangle(“FooBar”)  
> > > =\> “foo\_bar”  
> > > Name.unmangle(“my\_foo”)  
> > > =\> “MyFoo”

Re loading IronRuby.dll - the problem is that IronRuby is also a  
namespace in IronRuby.dll so there is a name conflict we don’t probably  
handle the best we could. Loading IronRuby.dll shouldn’t be a common  
scenario though. The best place for IronRuby specific functionality is  
in the IronRuby module. If you’re missing some let us know.

Tomas

From: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Orion E.  
Sent: Sunday, January 17, 2010 8:29 PM  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] Accessing classes defined in IronRuby.dll  
from within IronRuby (IronRuby 1.0RC1)

I am doing load\_assembly ‘IronRuby’, and it didn’t work (the example is  
copy/pasted pretty much verbatim). Not sure if that means your version  
of IR is different to mine, or what?

Cheers,  
On Mon, Jan 18, 2010 at 3:56 PM, Jimmy S.  
\<[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:  
load\_assembly ‘IronRuby’ will do the trick.

---

<div class="post-metadata">

**Author:** ![Orion\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/65b543/32.png) [@Orion\_E](https://www.ruby-forum.com/u/Orion_E)\
**Post date:** [January 18, 2010, 10:09pm UTC](https://www.ruby-forum.com/t/accessing-classes-defined-in-ironruby-dll-from-within-ironruby-ironruby-1-0rc1/181772/7 "2010-01-18T22:09:56Z")

</div>

They won’t probably work exactly the same way as IronRuby mangling  
though. So if you need this for CLR interop you should use  
IronRuby::Clr::Name class.

Tomas

From: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Orion E.  
Sent: Monday, January 18, 2010 12:41 PM  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] Accessing classes defined in IronRuby.dll  
from within IronRuby (IronRuby 1.0RC1)

Thanks for that Tomas.

I ended up copy/pasting the String#camelize and #underscore methods from  
rails as they were only a couple of lines long. This is probably less  
error prone than importing types from the IronRuby dll in the long run  
anyway 🙂

Cheers.  
On Mon, Jan 18, 2010 at 7:35 PM, Tomas M.  
\<[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:  
BTW, if you really needed to get to IronRuby.dll’s types you can use  
this workaround:

> > > Utils = System::Type.get\_type(‘IronRuby.Runtime.RubyUtils, IronRuby’).to\_class  
> > > =\> IronRuby::Runtime::RubyUtils  
> > > Utils.try\_unmangle\_name(“foo\_bar”)  
> > > =\> ‘FooBar’

Tomas

From:  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
On Behalf Of Tomas M.  
Sent: Sunday, January 17, 2010 10:24 PM

To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] Accessing classes defined in IronRuby.dll  
from within IronRuby (IronRuby 1.0RC1)

IronRuby is a module already defined in standard library. It gives you  
access to a bunch of useful APIs, including name mangling:

> > > IronRuby.singleton\_methods  
> > > =\> [“configuration”, “globals”, “load”, “loaded\_assemblies”,  
> > > “loaded\_scripts”, “require”, ‘create\_runtime’, ‘create\_engine’,  
> > > ‘create\_ruby\_setup’, ‘get\_engine’, ‘require\_file’,  
> > > ‘get\_execution\_context’]  
> > > IronRuby.constants  
> > > =\> [“Clr”, “Print”]  
> > > IronRuby::Clr.constants  
> > > =\> [“BigInteger”, “FlagEnumeration”, “Float”, “Integer”,  
> > > “MultiDimensionalArray”, “String”, “Name”, “Scope”]  
> > > IronRuby::Clr::Name.singleton\_methods(false)  
> > > =\> [“clr\_to\_ruby”, “mangle”, “ruby\_to\_clr”, “unmangle”]  
> > > include IronRuby::Clr  
> > > Name.mangle(“FooBar”)  
> > > =\> “foo\_bar”  
> > > Name.unmangle(“my\_foo”)  
> > > =\> “MyFoo”

Re loading IronRuby.dll - the problem is that IronRuby is also a  
namespace in IronRuby.dll so there is a name conflict we don’t probably  
handle the best we could. Loading IronRuby.dll shouldn’t be a common  
scenario though. The best place for IronRuby specific functionality is  
in the IronRuby module. If you’re missing some let us know.

Tomas

From:  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
On Behalf Of Orion E.  
Sent: Sunday, January 17, 2010 8:29 PM  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] Accessing classes defined in IronRuby.dll  
from within IronRuby (IronRuby 1.0RC1)

I am doing load\_assembly ‘IronRuby’, and it didn’t work (the example is  
copy/pasted pretty much verbatim). Not sure if that means your version  
of IR is different to mine, or what?

Cheers,  
On Mon, Jan 18, 2010 at 3:56 PM, Jimmy S.  
\<[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:  
load\_assembly ‘IronRuby’ will do the trick.
