# IronRuby not loading DLL

**URL:** <https://www.ruby-forum.com/t/ironruby-not-loading-dll/204918>\
**Category:** IronRuby\
**Created:** [March 24, 2011, 10:00pm UTC](https://www.ruby-forum.com/t/ironruby-not-loading-dll/204918 "2011-03-24T22:00:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [March 24, 2011, 10:00pm UTC](https://www.ruby-forum.com/t/ironruby-not-loading-dll/204918/1 "2011-03-24T22:00:51Z")

</div>

I have been using IronRuby for a while now to do simple scripting  
against DotNet DLLs with great success. I ran in to a problem recently  
where I am asking IronRuby 1.1.1 to require a DLL but it does not appear  
to be loaded. I do not get an error message but cannot instantiate any  
types from the DLL. If I do “p Object.constants” it does not return any  
namespaces or classes from the DLL.

When trying to do:  
“mdMATCHUPOBJECTLib::mdMUIncrementalClass.new”

I get the error:  
“undefined method mdMATCHUPOBJECTLib”

Where mdMUIncrementalClass is a class in the DLL and mdMATCHUPOBJECTLib  
is the namespace. This works perfectly in C#/VisualStudio with the same  
DLL (I am basically using the exact same code in C# and Ruby). If it  
helps, this is an Interop DLL created by Visual Studio from a COM DLL.

---

<div class="post-metadata">

**Author:** ![pozza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8e8cbc/32.png) [@pozza](https://www.ruby-forum.com/u/pozza)\
**Post date:** [March 25, 2011, 10:21pm UTC](https://www.ruby-forum.com/t/ironruby-not-loading-dll/204918/2 "2011-03-25T22:21:23Z")

</div>

I may be totally “off base,” but have you tried using the fusion viewer  
to ensure that you do not have a problem with .NET loading the DLL (and  
its underlying COM object).

* * *

Larry J.  
||| Senior Level Development Engineer  
Aspen Technology, Inc. ||| +1 281-504-3324 ||| fax: 281-584-1062 |||

> **[AspenTech | Asset Optimization Software - Asset Performance Management,...](https://www.aspentech.com/en/)**
>
> Our software tackles the most complex process manufacturing challenges, creating value and improving profitability for our customers. The industries that drive our economies and touch our lives are optimized by aspenONE software every day. The...

---

<div class="post-metadata">

**Author:** ![pozza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8e8cbc/32.png) [@pozza](https://www.ruby-forum.com/u/pozza)\
**Post date:** [March 26, 2011, 1:03am UTC](https://www.ruby-forum.com/t/ironruby-not-loading-dll/204918/3 "2011-03-26T01:03:25Z")

</div>

You need to use const\_get to access classes/namespaces whose names are  
not compatible with Ruby naming conventions.  
A module in Ruby must start with capital ASCII letter.

const\_get(:mdMATCHUPOBJECTLib).const\_get(:mdMUIncrementalClass).new  
should work.

Tomas

---

<div class="post-metadata">

**Author:** ![pozza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8e8cbc/32.png) [@pozza](https://www.ruby-forum.com/u/pozza)\
**Post date:** [March 26, 2011, 6:30pm UTC](https://www.ruby-forum.com/t/ironruby-not-loading-dll/204918/4 "2011-03-26T18:30:59Z")

</div>

Tomas, how would you feel about adding an optional block param to  
require/load\_assembly for overriding how .NET types are mapped to  
constants?  
That might be prove beneficial in cases such as these.

-Charles

On Fri, Mar 25, 2011 at 5:37 PM, Tomas M. \<

---

<div class="post-metadata">

**Author:** ![pozza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8e8cbc/32.png) [@pozza](https://www.ruby-forum.com/u/pozza)\
**Post date:** [March 27, 2011, 6:20am UTC](https://www.ruby-forum.com/t/ironruby-not-loading-dll/204918/5 "2011-03-27T06:20:28Z")

</div>

What would such block usually do? Uppercase the first letter of a  
lower-cased class/namespace? We could do that or some other mangling  
automatically. Is there any value in customizing the mangling?

Being it automatic would help you to discover the constants since they  
would appear in Module#constants.

Tomas

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Charles  
Strahan  
Sent: Saturday, March 26, 2011 10:00 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] IronRuby not loading DLL

Tomas, how would you feel about adding an optional block param to  
require/load\_assembly for overriding how .NET types are mapped to  
constants? That might be prove beneficial in cases such as these.

-Charles

On Fri, Mar 25, 2011 at 5:37 PM, Tomas M.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:  
You need to use const\_get to access classes/namespaces whose names are  
not compatible with Ruby naming conventions.  
A module in Ruby must start with capital ASCII letter.

const\_get(:mdMATCHUPOBJECTLib).const\_get(:mdMUIncrementalClass).new  
should work.

Tomas

---

<div class="post-metadata">

**Author:** ![pozza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8e8cbc/32.png) [@pozza](https://www.ruby-forum.com/u/pozza)\
**Post date:** [March 28, 2011, 2:20am UTC](https://www.ruby-forum.com/t/ironruby-not-loading-dll/204918/6 "2011-03-28T02:20:16Z")

</div>

I figured that it’s always nice to have options - especially if there  
are  
conflicts. Capitalizing the first letter would probably work in 99% of  
cases, but I could imagine there _might_ be case where you have an xFoo  
type  
and an XFoo type in the same namespace.

That’s probably being pedantic though - just capitalizing the first  
letter  
sounds like a pragmatic solution to me.

-Charles

On Sat, Mar 26, 2011 at 10:01 PM, Tomas M. \<

---

<div class="post-metadata">

**Author:** ![pozza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8e8cbc/32.png) [@pozza](https://www.ruby-forum.com/u/pozza)\
**Post date:** [March 28, 2011, 3:46am UTC](https://www.ruby-forum.com/t/ironruby-not-loading-dll/204918/7 "2011-03-28T03:46:02Z")

</div>

You can always use const\_get for the 1% cases. IMO, having  
non-capitalized namespaces and classes is already 1% case, since such  
libraries violate .NET design guidelines.

Tomas

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Charles  
Strahan  
Sent: Sunday, March 27, 2011 4:19 PM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] IronRuby not loading DLL

I figured that it’s always nice to have options - especially if there  
are conflicts. Capitalizing the first letter would probably work in 99%  
of cases, but I could imagine there might be case where you have an xFoo  
type and an XFoo type in the same namespace.

That’s probably being pedantic though - just capitalizing the first  
letter sounds like a pragmatic solution to me.

-Charles  
On Sat, Mar 26, 2011 at 10:01 PM, Tomas M.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:  
What would such block usually do? Uppercase the first letter of a  
lower-cased class/namespace? We could do that or some other mangling  
automatically. Is there any value in customizing the mangling?

Being it automatic would help you to discover the constants since they  
would appear in Module#constants.

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)]  
On Behalf Of Charles S.  
Sent: Saturday, March 26, 2011 10:00 AM

To: removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby not loading DLL

Tomas, how would you feel about adding an optional block param to  
require/load\_assembly for overriding how .NET types are mapped to  
constants? That might be prove beneficial in cases such as these.

-Charles

On Fri, Mar 25, 2011 at 5:37 PM, Tomas M.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:  
You need to use const\_get to access classes/namespaces whose names are  
not compatible with Ruby naming conventions.  
A module in Ruby must start with capital ASCII letter.

const\_get(:mdMATCHUPOBJECTLib).const\_get(:mdMUIncrementalClass).new  
should work.

Tomas

---

<div class="post-metadata">

**Author:** ![pozza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8e8cbc/32.png) [@pozza](https://www.ruby-forum.com/u/pozza)\
**Post date:** [March 28, 2011, 6:16am UTC](https://www.ruby-forum.com/t/ironruby-not-loading-dll/204918/8 "2011-03-28T06:16:45Z")

</div>

> You can always use const\_get for the 1% cases. IMO, having non-capitalized  
> namespaces and classes is already 1% case, since such libraries violate .NET  
> design guidelines.

That’s a valid point. I’t would be trivial to write a script to re-map  
types to Ruby constants in the 1% case; my suggestion is probably not  
worth  
implementing in IronRuby directly.

-Charles

On Sun, Mar 27, 2011 at 8:44 PM, Tomas M. \<

---

<div class="post-metadata">

**Author:** ![pozza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8e8cbc/32.png) [@pozza](https://www.ruby-forum.com/u/pozza)\
**Post date:** [April 1, 2011, 9:31pm UTC](https://www.ruby-forum.com/t/ironruby-not-loading-dll/204918/9 "2011-04-01T21:31:37Z")

</div>

> I could imagine there _might_ be case where you have an xFoo type and an  
> XFoo type in the same namespace  
> BTW, differentiating types or public members by case isn’t CLS  
> compliant,  
> which basically means that who ever wrote that code should be expecting  
> some  
> interop issues.

Miguel A. Madero Reyes  
[www.miguelmadero.com](http://www.miguelmadero.com) (blog)  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

On Mon, Mar 28, 2011 at 7:19 AM, Charles S. \<
