Jeff Dik
2008-Jun-06 20:22 UTC
[Ironruby-core] Difference between requiring a DLL versus using an assembly name?
Hi,
A couple weeks ago, I started using IronRuby to unit test my C# code.
I was amazed how well it worked. The IronRuby team has done an
amazing job! I''m tremendously impressed.
When I first started using IronRuby, support for requiring DLLs had
just been removed. Because of this, I had the Rake "spec" task copy
the DLLs I was going to test to the directory containing ir.exe.
Yesterday I started modifying the code to require the DLLs instead of
using the assembly names. This works fine for my non-signed DLLs, but
for some reason doesn''t work with the signed Rhino.Mocks.dll. (This
is with revision r113.)
Below is transcript of the issue I found. In the interactive IronRuby
session, notice how the code doesn''t work when the Rhino.Mocks.dll is
required, but does work after ''Rhino.Mocks, Version=2.9.6.40350,
Culture=neutral, PublicKeyToken=0b3305902db7183f'' is required.
d:/jad/tmp/Foo $ cat Bar.cs
namespace Foo
{
using System;
using Rhino.Mocks;
public class Bar
{
private MockRepository mocks;
public Bar(MockRepository mocks)
{
this.mocks = mocks;
}
}
}
d:/jad/tmp/Foo $ ls
Bar.cs Rhino.Mocks.dll
d:/jad/tmp/Foo $ csc /t:library /r:Rhino.Mocks.dll Bar.cs
Microsoft (R) Visual C# .NET Compiler version 7.10.6001.4
for Microsoft (R) .NET Framework version 1.1.4322
Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.
d:/jad/tmp/Foo $ ls
Bar.cs Bar.dll Rhino.Mocks.dll
d:/jad/tmp/Foo $ ls ~/tmp/ironruby/trunk/build/debug/Rhino.Mocks.dll
d:/jad/tmp/ironruby/trunk/build/debug/Rhino.Mocks.dll
d:/jad/tmp/Foo $ ir
IronRuby 1.0.0.0 on .NET 2.0.50727.1433
Copyright (c) Microsoft Corporation. All rights reserved.
Note that local variables do not work today in the console.
As a workaround, use globals instead (eg $x = 42 instead of x = 42).
>>> require ''Rhino.Mocks.dll''
=> true>>> require ''Bar.dll''
=> true>>> $mocks = Rhino::Mocks::MockRepository.new
=> #<Rhino::Mocks::MockRepository:0x000005c>>>> $bar = Foo::Bar.new($mocks)
:0:in `Initialize##14'': wrong number or type of arguments for
`Foo::Bar'' (ArgumentError)
>>> require ''Rhino.Mocks, Version=2.9.6.40350,
Culture=neutral, PublicKeyToken=0b3305902db7183f''
=> true>>> $mocks = Rhino::Mocks::MockRepository.new
=> #<Rhino::Mocks::MockRepository:0x000005e>>>> $bar = Foo::Bar.new($mocks)
=> #<Foo::Bar:0x0000060>>>> exit
Is this a bug, or am I doing something incorrectly?
Thanks,
Jeff