[Mono-list] dll with same name causes missing method exceptions (mono 0.91)

Dolapo M Falola dolapo@minivishnu.net
Sat, 22 May 2004 23:52:38 -0500


Is the following expected behavior:

1) A class or set of classes compiled as a library with a name x.
2) An executable with classes with different name that references that 
library with name x builds.
3) Attempting to run the built executable throws NoSuchMethodExceptions.

Example:
[File:ClassA.cs]:
using System;
namespace Namespace.A {
     public class ClassA {
         public void DoIt() {
             Console.WriteLine("Done!");
         }
     }
}
Compile with: mcs /out:ClassB.dll /target:library ClassA.cs

[File:ClassB.cs]:
using Namespace.A;
namespace Namespace.B {
     public class ClassB {
         public static void Main() {
             ClassA ca = new ClassA();
             ca.DoIt();
         }
     }
}
Compile with: mcs /out:ClassB.exe /r:ClassB.dll ClassB.cs

Executing: mono ClassB.exe
yields:
** (ClassB.exe:32278): WARNING **: Could not load class from token 
0x01000002 in /home/dolapo/code/diffname/ClassB.exe

** (ClassB.exe:32278): WARNING **: Missing method .ctor in assembly 
/home/dolapo/code/diffname/ClassB.exe typeref index 2

Unhandled Exception: System.NullReferenceException: A null value was 
found where an object instance was required.
in (unmanaged) Namespace.B.ClassB:Main ()

I would expect an error of the form: "Could not find assembly..." which 
would have occured if I'd named the dll ClassA.dll then removed it, ala:
** (ClassB.exe:32305): WARNING **: Could not find assembly ClassA, 
references from /home/dolapo/code/diffname/ClassB.exe (assemblyref_index=1)
      Major/Minor: 0,0
      Build:       0,0
      Token:       (null)


Unhandled Exception: System.NullReferenceException: A null value was 
found where an object instance was required.

My environment info:
Mono JIT compiler version 0.91, (C) 2002-2004 Novell, Inc and 
Contributors. www.go-mono.com
         TLS:           normal
         GC:            Included Boehm (with typed GC)
         SIGSEGV      : altstack
         Globalization: ICU


Thanks
Dolapo