title: How can I target a specific language version using CodeDOM?
body: <p>Using the C#  code provider and the  <code>ICodeCompiler.CompileAssemblyFromSource</code> method, I am attempting to compile a code file in order to produce an executable assembly. </p>
  
  <p>The code that I would like to compile makes use of features such as optional parameters and extension methods that are only available when using the language C# 4. </p>
  
  <p>Having said that, the code that I would like to compile only requires (and <em>needs</em>) to target version 2.0 of the .NET Framework. </p>
  
  <hr>
  
  <p>Using the proceeding code it is possible to avoid any compile-time errors pertaining to syntax however, the resulting assembly will target version 4.0 of the framework which is undesirable.  </p>
  
  <pre><code>var compiler = new CSharpCodeProvider(
          new Dictionary&lt;string, string&gt; { { "CompilerVersion", "v4.0" } } );
  </code></pre>
  
  <p>How can I make is so that the code provider targets <em>language</em> version 4.0 but produces an assembly that only requires version 2.0 of the <em>framework</em>? </p>