.NET doesn't like having two assemblies that differ only by extension.
To the runtime TestNAnt.dll and TestNAnt.exe look exactly the same. When it
tries to resolve the type "TestNAnt.UsedClass, TestNAnt, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null" it looks to see if it has an assembly
called "TestNAnt, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" in
memory. It finds TestNAnt.exe, and so it looks in there for
TestNAnt.UsedClass. When it doesn't find it, it throws the exception you
see.
The solution is to name your assemblies different things.
john
----- Original Message -----
From: "Clark Dorman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, January 15, 2003 8:52 AM
Subject: [Nant-users] NAnt and Libraries: Unable to Load Class
> I am new to C# and .NET and I having a problem creating an executable that
> works when I first create a library. I used the NAnt build file as a
basis.
> The project has two C# files: UsedClass and MainClass in a src
directory.
> They are both empty except that MainClass has a Main function that creates
a
> UsedClass instance. The build file is supposed to create a dll and then
the
> executable. It seems to compile fine but when I try to run the executable
> from the command line, it says that it is unable to load UsedClass. Here
is
> the error:
>
> Unhandled Exception: System.TypeLoadException: Could not load type
> TestNAnt.UsedClass from assembly TestNAnt, Version=0.0.0.0,
Culture=neutral,
> PublicKeyToken=null.
> at TestNAnt.MainClass.Main(String[] args)
>
> The build directory has the created files TestNAnt.dll and TestNAnt.exe.
> Here is part of the build file:
>
> <target name="build" depend="clean" description="compiles the source
> code">
> <mkdir dir="${build.dir}"/>
>
> <!-- Make the dll -->
> <csc target="library"
> output="${build.dir}\${project.Formalname}.dll" debug="${debug}">
> <sources basedir="${src.dir}">
> <includes name="**/*.cs"/>
> <excludes name="MainClass.cs"/>
> </sources>
> </csc>
>
> <!-- Compile TestNAnt.exe -->
> <csc target="exe" output="${build.dir}\${project.Formalname}.exe"
> debug="${debug}">
> <sources basedir="${src.dir}">
> <includes name="MainClass.cs"/>
> </sources>
> <references>
> <includes name="${build.dir}/${project.Formalname}.dll"/>
> </references>
> </csc>
> </target>
>
> Any help in understanding why this is happening would be greatly
> appreciated. I don't know if I am supposed to register the DLL somewhere
or
> compile it differently.
>
> Clark Dorman
>
>
> _________________________________________________________________
> The new MSN 8 is here: Try it free* for 2 months
> http://join.msn.com/?page=dept/dialup
>
>
>
> -------------------------------------------------------
> This SF.NET email is sponsored by: Take your first step towards giving
> your online business a competitive advantage. Test-drive a Thawte SSL
> certificate - our easy online guide will show you how. Click here to get
> started: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0027en
> _______________________________________________
> Nant-users mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/nant-users
-------------------------------------------------------
This SF.NET email is sponsored by: A Thawte Code Signing Certificate
is essential in establishing user confidence by providing assurance of
authenticity and code integrity. Download our Free Code Signing guide:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0028en
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users