hi,
i want to develop a window application that will get a '.cs
file' as input from a text box and create a class library(.dll file)
for it.
this is the method i used to programmatically compile code and generate the executable, but i want to generate a dll.
private void Compile()
{
CSharpCodeProvider codeProvider = new CSharpCodeProvider();
ICodeCompiler icc = codeProvider.CreateCompiler();
string Output = "testAssembly.exe";
System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters();
parameters.GenerateExecutable = true;
parameters.OutputAssembly = Output;
CompilerResults results = icc.CompileAssemblyFromSource(parameters, txtOutput.Text.ToString());
//txtOutput is the text box where i give my code
if (results.Errors.Count > 0)
{
foreach (CompilerError CompErr in results.Errors)
{
MessageBox.Show( "Line number " + CompErr.Line +
", Error Number: " + CompErr.ErrorNumber +
", '" + CompErr.ErrorText + ";" +
Environment.NewLine + Environment.NewLine);
}
}
else
{
MessageBox.Show("Success");
}
}
this is the link i referred for programmatically compiling code using C# compiler that creates exe.
http://support.microsoft.com/kb/304655
help plz,
thanx in advance.
Loading
PragadheeshPosted Jan 28, 2009, 8:43 AM
this is the error that i get when i load the assembly in NUnit,
"System.IO,FileNotFoundException : Could not load file or assembly 'nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' or one of its dependecies. The system cannot find the file specified."
or what is d cause of this error.! how to solve it.?
Mamta MPosted Jan 27, 2009, 5:57 AM
Hi,
All you need to do is specify
parameters.GenerateExecutable = false;
and specify the name of your dll file in the Output string.
Hope that helps.
-Mamta