[Mono-list] "WARNING **: Could not load class from token" error

Erik Pukinskis erik@snowedin.net
Sat, 22 May 2004 15:50:42 -0400


Hi everyone,

I seem to have a problem with my build environment that I have been
trying to fix for the past several days to no avail.  Basically, when I
build my project with one set of names for the executable and libraries,
it works fine, but with another set of names it fails:


[erik@localhost test]$ mcs -target:library -out:Foo.dll Foo.cs
=EF=BB=BFCompilation succeeded
[erik@localhost test]$ mcs -r:Modality.dll -out:Bar.exe Bar.cs
=EF=BB=BFCompilation succeeded
[erik@localhost test]$ mono Bar.exe
=EF=BB=BFOK!
[erik@localhost test]$ mcs -target:library -out:Modality.dll Foo.cs
=EF=BB=BFCompilation succeeded
[erik@localhost test]$ mcs -r:Modality.dll -out:Modality.exe Bar.cs
=EF=BB=BFCompilation succeeded
[erik@localhost test]$ mono Modality.exe
=20
** (Modality.exe:24179): WARNING **: Could not load class from token
0x01000002 in /home/erik/tmp/test/Modality.exe
=20
** (Modality.exe:24179): WARNING **: Missing method .ctor in
assembly /home/erik/tmp/test/Modality.exe typeref index 2
=20
Unhandled Exception: System.NullReferenceException: A null value was
found where an object instance was required.
in (unmanaged) Bar:Main (string[])
=20

For some reason the problem only appears when I use those two names
(Modality.dll and Modality.exe).  I even tried doing a clean reinstall
(since I was upgrading to Fedora Core 2 anyway) and trying it again, and
I still have the same problem.  I'm at a total loss, can anyone help?

-Erik


P.S. Here are the contents of the two source files in question:

Foo.cs:
public class Foo
{
=20
}

Bar.cs:
using System;
public class Bar
{
        public static void Main(string[] args)
        {
                Foo f =3D new Foo();
                Console.WriteLine("OK!");
        }
}