title: CodeDom Compiler for C#
body: <p>I have been trying to get CodeDom to work so I can dynamically create code for my application during runtime. However, after many tutorials and trial and error, I have come into a problem I can't seem to pass. I keep getting compiler errors on code that looks exactly like it should. I get "Unrecognized escape sequence '\'" when there is no '\' anywhere in my code.</p>
  
  <p>The errors I get are all on line 1. Here they are in order:
  CS1009
  CS1056 (3 times in a row)
  CS0116</p>
  
  <p>Here is what I have:</p>
  
  <p>The code being compiled:</p>
  
  <pre><code>using System;
  using System.Windows.Forms;
  namespace sdjkfhj 
  {    
      public class Sample 
      {
          public static void main()
          {
              MessageBox.Show("Working");
              return;
          }
      }
  }
  </code></pre>
  
  <p>And the compiler code is as follows:</p>
  
  <pre><code>public void Compile(string file)
      {
          var prov = new Dictionary&lt;string, string&gt;();
          prov.Add("CompilerVersion", "v2.0");
          CSharpCodeProvider c = new CSharpCodeProvider();
          ICodeCompiler comp = c.CreateCompiler();
  
          CompilerParameters param = new CompilerParameters();
          param.GenerateExecutable = true;
          param.OutputAssembly = file + ".exe";
          param.ReferencedAssemblies.Add("System.dll");
          param.ReferencedAssemblies.Add("System.Windows.Forms.dll");
          if (c.Supports(GeneratorSupport.EntryPointMethod))
              param.MainClass = "Sample";
  
          CompilerResults results = comp.CompileAssemblyFromSource(param, file);
  
          if (results.Errors.Count &gt; 0)
          {
              foreach (CompilerError CompErr in results.Errors)
              {
                  MessageBox.Show("Line number " + CompErr.Line + ", Error Number: " + CompErr.ErrorNumber + ", '" + CompErr.ErrorText + ";" + Environment.NewLine + Environment.NewLine);
              }
          }
      }
  </code></pre>
  
  <p>Is there something I'm not doing to compile it right? Are there things I'm missing? I'm kind of lost here. Thanks in advance.</p>