# Using .Net cascade assemblies

**URL:** <https://www.ruby-forum.com/t/using-net-cascade-assemblies/222134>\
**Category:** IronRuby\
**Created:** [August 14, 2012, 7:41am UTC](https://www.ruby-forum.com/t/using-net-cascade-assemblies/222134 "2012-08-14T07:41:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [August 14, 2012, 7:41am UTC](https://www.ruby-forum.com/t/using-net-cascade-assemblies/222134/1 "2012-08-14T07:41:19Z")

</div>

Hello.

I’ve got 2 .Net assemblies, for example, Foo.dll and Boo.dll

Boo contains  
namespace BooModule  
{  
public class Boo  
{  
public string Speak()  
{  
return “Hello from class Boo”;  
}  
}

public interface IFoo  
{  
string Comment();  
}  
}

Foo contains

namespace FooModule  
{  
public class Foo : IFoo  
{  
public string Comment()  
{  
return “Class Foo inhereted from IFoo”;  
}  
}  
}

In IronRuby console I try:

IronRuby 1.1.3.0 on .NET 4.0.30319.239  
Copyright © Microsoft Corporation. All rights reserved.

> > > require ‘D:\Programs\Univeris\FooBoo\bin\Boo’  
> > > =\> true
> 
> > > include BooModule  
> > > =\> Object
> 
> > > require ‘D:\Programs\Univeris\FooBoo\bin\Foo’  
> > > =\> true
> 
> > > include FooModule  
> > > (ir):1:in `const\_missing’: uninitialized constant Object::FooModule  
> > > (NameError)  
> > > from (ir):1

If I inherit Foo : Boo I get the same error.

But if I move the declaration to the Foo propject, so it’s like

namespace FooModule  
{  
public interface IFoo  
{  
string Comment();  
}

public class Foo : IFoo  
{  
public string Comment()  
{  
return “Class Foo inhereted from IFoo”;  
}  
}  
}

Everything works just fine.

IronRuby 1.1.3.0 on .NET 4.0.30319.239  
Copyright © Microsoft Corporation. All rights reserved.

> > > require ‘D:\Programs\Univeris\FooBoo\bin\Foo’  
> > > =\> true
> 
> > > include FooModule  
> > > =\> Object
> 
> > > foo = Foo.new  
> > > =\> FooModule.Foo
> 
> > > foo.Comment  
> > > =\> ‘Class Foo inhereted from IFoo’

But I’ve got a really huge program system that consists of several big  
dll libraries which I want to use via IronRuby and I just can’t move all  
those libraries into one dll file and into one namespace.

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![subzero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bbce88/32.png) [@subzero](https://www.ruby-forum.com/u/subzero)\
**Post date:** [August 14, 2012, 11:27pm UTC](https://www.ruby-forum.com/t/using-net-cascade-assemblies/222134/2 "2012-08-14T23:27:19Z")

</div>

* * *

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

---

<div class="post-metadata">

**Author:** ![subzero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bbce88/32.png) [@subzero](https://www.ruby-forum.com/u/subzero)\
**Post date:** [August 15, 2012, 7:22am UTC](https://www.ruby-forum.com/t/using-net-cascade-assemblies/222134/3 "2012-08-15T07:22:43Z")

</div>

Orion E. wrote in post #1072378:

> I’m not sure exactly why this happens, I think it’s something to do with  
> how the .NET runtime itself delay-loads assemblies and the rules it has  
> for looking for dependent dll’s

> There are three ways I know of to work around this:

> 1. Use Dir.chdir to switch your working directory to  
> D:\Programs\Univeris\FooBoo\bin before you start loading the dll’s
> 2. Add to ruby’s load path using $: \<\< ‘D:\Programs\Univeris\FooBoo\bin’
> 3. Hook the CLR’s AssemblyResolve event… this is a bit more complicated,  
> you can look up how this works on MSDN or I can tell you more if you’d  
> like
> 
> * * *
> 
> Ironruby-core mailing list  
> [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)

Thank you very much. Everything worked just fine.
