EDN Admin
Well-known member
Im using the codedomprovider to compile exes but when referencing my own dll within the running program it throws an error when the compiled exe is run because its not putting the dll in the exe folder (it works fine when referencing standard .net dlls.
How do I tell the compiler to put dlls in the exe folder when compiling? I presume it can be done as when I compile a project is VS2010 and reference my own libraries it saves the dll in the /bin/debug folder.
I could do it with code manually but not all dlls need to go in the exe folder eg the standard .NET libraries. I presume its a compiler option but info on these classes are hard to find. Some of the code used is below:
<div style="color:black; background-color:white
<pre> CodeDomProvider provider = CodeDomProvider.CreateProvider(<span style="color:#a31515 "CSharp");
CompilerParameters cp = <span style="color:blue new CompilerParameters();
<span style="color:green // Generate an executable instead of
<span style="color:green // a class library.
cp.GenerateExecutable = <span style="color:blue true;
<span style="color:green // Set the assembly file name to generate.
cp.OutputAssembly = output;
<span style="color:green // Generate debug information.
cp.IncludeDebugInformation = <span style="color:blue true;
<span style="color:green // Add all assembly reference from reference list class
<span style="color:blue foreach (<span style="color:blue string str <span style="color:blue in mainControl.ReferenceList.ReferenceL)
{
cp.ReferencedAssemblies.Add(str);
}
<span style="color:green // Save the assembly as a physical file.
cp.GenerateInMemory = <span style="color:blue false;
<span style="color:green // Set the level at which the compiler
<span style="color:green // should start displaying warnings.
cp.WarningLevel = warningLevel;
<span style="color:green // Set whether to treat all warnings as errors.
cp.TreatWarningsAsErrors = <span style="color:blue false;
<span style="color:green // Set compiler argument to optimize output.
cp.CompilerOptions = <span style="color:#a31515 "/optimize";
cp.CompilerOptions = <span style="color:#a31515 "/platform:x86";
<span style="color:green // Set a temporary files collection.
<span style="color:green // The TempFileCollection stores the temporary files
<span style="color:green // generated during a build in the current directory,
<span style="color:green // false deletes them after use
mainControl.DebugControl.DebugBox.AppendText(<span style="color:#a31515 "Creating temp files...");
cp.TempFiles = <span style="color:blue new TempFileCollection(<span style="color:#a31515 ".", <span style="color:blue false);
[/code]
<br/>
<br/>
<br/>
View the full article
How do I tell the compiler to put dlls in the exe folder when compiling? I presume it can be done as when I compile a project is VS2010 and reference my own libraries it saves the dll in the /bin/debug folder.
I could do it with code manually but not all dlls need to go in the exe folder eg the standard .NET libraries. I presume its a compiler option but info on these classes are hard to find. Some of the code used is below:
<div style="color:black; background-color:white
<pre> CodeDomProvider provider = CodeDomProvider.CreateProvider(<span style="color:#a31515 "CSharp");
CompilerParameters cp = <span style="color:blue new CompilerParameters();
<span style="color:green // Generate an executable instead of
<span style="color:green // a class library.
cp.GenerateExecutable = <span style="color:blue true;
<span style="color:green // Set the assembly file name to generate.
cp.OutputAssembly = output;
<span style="color:green // Generate debug information.
cp.IncludeDebugInformation = <span style="color:blue true;
<span style="color:green // Add all assembly reference from reference list class
<span style="color:blue foreach (<span style="color:blue string str <span style="color:blue in mainControl.ReferenceList.ReferenceL)
{
cp.ReferencedAssemblies.Add(str);
}
<span style="color:green // Save the assembly as a physical file.
cp.GenerateInMemory = <span style="color:blue false;
<span style="color:green // Set the level at which the compiler
<span style="color:green // should start displaying warnings.
cp.WarningLevel = warningLevel;
<span style="color:green // Set whether to treat all warnings as errors.
cp.TreatWarningsAsErrors = <span style="color:blue false;
<span style="color:green // Set compiler argument to optimize output.
cp.CompilerOptions = <span style="color:#a31515 "/optimize";
cp.CompilerOptions = <span style="color:#a31515 "/platform:x86";
<span style="color:green // Set a temporary files collection.
<span style="color:green // The TempFileCollection stores the temporary files
<span style="color:green // generated during a build in the current directory,
<span style="color:green // false deletes them after use
mainControl.DebugControl.DebugBox.AppendText(<span style="color:#a31515 "Creating temp files...");
cp.TempFiles = <span style="color:blue new TempFileCollection(<span style="color:#a31515 ".", <span style="color:blue false);
[/code]
<br/>
<br/>
<br/>
View the full article