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

Reply via email to