Constant error in compiler using C#'s provided objects
<p>I have used the built in C# methods to write a compiler, like the following:</p>

<pre><code>CodeDomProvider codeProvider = CodeDomProvider.CreateProvider("CSharp");
string Output = "Out.exe";
Button ButtonObject = (Button)sender;

this.RadTextBox1.Text = string.Empty;

System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters();

//Make sure we generate an EXE, not a DLL
parameters.GenerateExecutable = true;
parameters.OutputAssembly = Output;

CompilerResults results = codeProvider.CompileAssemblyFromSource(parameters, RadTextBox1.Text);

if (results.Errors.Count &gt; 0)
{
    RadTextBox2.ForeColor = Color.Red;
    foreach (CompilerError CompErr in results.Errors)
    {
        RadTextBox2.Text = RadTextBox2.Text +
                    "Line number " + CompErr.Line +
                    ", Error Number: " + CompErr.ErrorNumber +
                    ", '" + CompErr.ErrorText + ";" +
                    Environment.NewLine + Environment.NewLine;
    }
}

else
{
    //Successful Compile
    RadTextBox2.ForeColor = Color.Blue;

    Guid guid =            Guid.NewGuid();

    string PathToExe = Server.MapPath(Path.Combine(@"\Compiled" , Output));

    FileStream fs = System.IO.File.Create(PathToExe);

    using (StreamWriter sw = new StreamWriter(fs))
    {
        sw.Write(RadTextBox1.Text);
    }

    Response.WriteFile(PathToExe);
</code></pre>

<p>When I run this code and write a Main method (such as the code sample in <a href="http://msdn.microsoft.com/en-us/library/ms228506(VS.80).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms228506(VS.80).aspx</a>, I get this error:</p>

<p>Line number 0, Error Number: CS5001, 'Program 'c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Out.exe' does not contain a static 'Main' method suitable for an entry point;</p>

<p>The code above is used as the basis of a compiler on my site (not yet live). So you type in code and generate an .exe assembly. But when I enter code into the textbox for code writing (Radtextbox1), even with a main method, I get the error.</p>

<p>What gives?</p>

<p>Thanks</p>
