Forum: IronRuby Using .Net cascade assemblies

382c3ae328b21e529ea0f5ddb1514abc?d=identicon&s=25 Alexander Ranger (strider_ajr)
on 2012-08-14 07:41
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 (c) 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 (c) 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?
D7aaf307f96bbdf5ff39be313fe581be?d=identicon&s=25 Orion Edwards (Guest)
on 2012-08-14 23:27
(Received via mailing list)
_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core
382c3ae328b21e529ea0f5ddb1514abc?d=identicon&s=25 Alexander Ranger (strider_ajr)
on 2012-08-15 07:22
Orion Edwards 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
> Ironruby-core@rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core

Thank you very much. Everything worked just fine.
This topic is locked and can not be replied to.