[Mono-list] Link against a DLL? (System.TypeLoadException)
Doug
douglas.linder at gmail.com
Mon May 23 03:58:34 EDT 2011
I'm having some trouble compiling a DLL and linking against it.
Should be trivial, so I must be doing something wrong; I keep getting the
error:
** (./a.out:27535): WARNING **: The class HelloLib.Hello could not be
loaded, used in a, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Unhandled Exception: System.TypeLoadException: Could not load type
'HelloLib.Hello' from assembly 'a, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null'.
I've written a very basic test case as shown below to illustrate my issue:
hello.cs:
using System;
namespace HelloLib {
public class Hello {
public void World() {
Console.WriteLine("Hello World");
}
}
}
assembly.cs:
sing System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("HelloLib")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HelloLib")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("1.0.0")]
Compiles ok via:
gmcs /debug- /target:library ./AssemblyInfo.cs ./hello.cs /out:a.dll
--
main.cs:
using System;
using HelloLib;
public class App {
static public void Main() {
var h = new HelloLib.Hello();
h.World();
}
}
Compiles ok via:
gmcs /debug+ /warn:4 /reference:./a.dll ./main.cs /out:a.out
...
But when I run it I get:
** (./a.out:27535): WARNING **: The class HelloLib.Hello could not be
loaded, used in a, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Unhandled Exception: System.TypeLoadException: Could not load type
'HelloLib.Hello' from assembly 'a, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null'.
What am I doing wrong?
Obviously this works fine:
gmcs /debug+ /warn:4 ./hello.cs ./main.cs /out:a.out
~
Doug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20110523/cac151c0/attachment.html
More information about the Mono-list
mailing list