Cant compile programmatically (please help!)
I'm trying to programmatically compile the file 'WebForm1.aspx.cs' wich is
a code behind source document. Now I get the following errors:
The type or namespace name 'ComponentModel' does not exist in the class or
namespace 'System' (are you missing an assembly reference?)
The type or namespace name 'Drawing' does not exist in the class or namespace
'System' (are you missing an assembly reference?)
The type or namespace name 'Web' does not exist in the class or namespace
'System' (are you missing an assembly reference?)
The type or namespace name 'Data' does not exist in the class or namespace
'System' (are you missing an assembly reference?)
The type or namespace name 'OleDbConnection' could not be found (are you
missing a using directive or an assembly reference?)
Please I appreciate any comment or help on this. Even if you read this now
and don't understand then let me know and I can explain.
Here is the source code:
CSharpCodeProvider cscp = new CSharpCodeProvider();
ICodeCompiler icc= cscp.CreateCompiler();
CompilerParameters cpar = new CompilerParameters();
CompilerResults results;
cpar.GenerateExecutable = true;
cpar.OutputAssembly = "out.exe";
results = icc.CompileAssemblyFromFile(cpar, "WebForm1.aspx.cs");
if(results.Errors.Count>0)
{
string strerr="";
foreach(CompilerError comperr in results.Errors)
{
strerr+=comperr.ErrorText;
strerr+="\r\n";
}
textBox1.Text=strerr;
}
else
{
MessageBox.Show("Success");
}
Yours sincerely
Andla

