title: Using C# 6 features with CodeDomProvider (Roslyn)
body: <pre><code>CodeDomProvider objCodeCompiler = CodeDomProvider.CreateProvider( "CSharp" );
  
  CompilerParameters objCompilerParameters = new CompilerParameters();
  
  ...
  
  CompilerResults objCompileResults = objCodeCompiler.CompileAssemblyFromFile( objCompilerParameters, files.ToArray() );
  </code></pre>
  
  <p>When I compile my files I get: </p>
  
  <blockquote>
    <p>FileFunctions.cs(347): Error: Unexpected character '$'</p>
  </blockquote>
  
  <p>Does anyone know how to get string interpolation working with CodeDom compiling?</p>
  
  <p>I found this link: <a href="https://stackoverflow.com/questions/13253967/how-to-target-net-4-5-with-csharpcodeprovider">How to target .net 4.5 with CSharpCodeProvider?</a></p>
  
  <p>So I tried: </p>
  
  <pre><code>     var providerOptions = new Dictionary&lt;string, string&gt;();
       providerOptions.Add( "CompilerVersion", "v4.0" );
  
       // Instantiate the compiler.
       CodeDomProvider objCodeCompiler = CodeDomProvider.CreateProvider( "CSharp", providerOptions );
  </code></pre>
  
  <p>But I still get the same error.</p>
  
  <p>I also updated the target framework to .NET Framework 4.6.</p>
  
  <p>NOTE: I can't specify "v4.5" or "v4.6" or I will get:</p>
  
  <pre><code>************** Exception Text **************
  System.InvalidOperationException: Compiler executable file csc.exe cannot be found.
     at System.CodeDom.Compiler.RedistVersionInfo.GetCompilerPath(IDictionary`2 provOptions, String compilerExecutable)
     at Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters options, String[] fileNames)
     at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromFileBatch(CompilerParameters options, String[] fileNames)
     at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile(CompilerParameters options, String[] fileNames)
     at Dynamic.CodeDOMCompiler.CompileAllCodeFiles() in C:\Users\Derek.Morin\Documents\Visual Studio 2010\Projects\ScriptCode\ScriptCode.ConvertedToC#\Core\CodeDOMCompiler.cs:line 93
     at NewForm.InitializeSystem() in C:\Users\Derek.Morin\Documents\Visual Studio 2010\Projects\ScriptCode\ScriptCode.ConvertedToC#\NewForm.cs:line 179
     at NewForm.NewForm_Load(Object sender, EventArgs e) in C:\Users\Derek.Morin\Documents\Visual Studio 2010\Projects\ScriptCode\ScriptCode.ConvertedToC#\NewForm.cs:line 111
     at System.Windows.Forms.Form.OnLoad(EventArgs e)
  </code></pre>
  
  <p>I have tried using the suggestion by Thomas Levesque:</p>
  
  <pre><code>CodeDomProvider objCodeCompiler = new Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider();
  </code></pre>
  
  <p>But then I get:</p>
  
  <pre><code>************** Exception Text **************
  System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\Derek.Morin\Documents\Visual Studio 2010\Projects\ScriptCode\ScriptCode.ConvertedToC#\bin\x86\Debug\bin\roslyn\csc.exe'.
     at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
     at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
     at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
     at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.get_CompilerName()
     at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.FromFileBatch(CompilerParameters options, String[] fileNames)
     at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.CompileAssemblyFromFileBatch(CompilerParameters options, String[] fileNames)
     at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile(CompilerParameters options, String[] fileNames)
     at Dynamic.CodeDOMCompiler.CompileAllCodeFiles() in C:\Users\Derek.Morin\Documents\Visual Studio 2010\Projects\ScriptCode\ScriptCode.ConvertedToC#\Core\CodeDOMCompiler.cs:line 87
     at NewForm.InitializeSystem() in C:\Users\Derek.Morin\Documents\Visual Studio 2010\Projects\ScriptCode\ScriptCode.ConvertedToC#\NewForm.cs:line 179
     at NewForm.NewForm_Load(Object sender, EventArgs e) in C:\Users\Derek.Morin\Documents\Visual Studio 2010\Projects\ScriptCode\ScriptCode.ConvertedToC#\NewForm.cs:line 111
     at System.Windows.Forms.Form.OnLoad(EventArgs e)
  </code></pre>
  
  <p>I'm not sure why it is trying to look for "csc.exe" in a subfolder of my bin directory.</p>
  
  <p>This path exists:</p>
  
  <blockquote>
    <p>C:\Users\Derek.Morin\Documents\Visual Studio
    2010\Projects\ScriptCode\ScriptCode.ConvertedToC#\bin\x86\Debug\roslyn</p>
  </blockquote>
  
  <p>But it was looking for:</p>
  
  <blockquote>
    <p>C:\Users\Derek.Morin\Documents\Visual Studio
    2010\Projects\ScriptCode\ScriptCode.ConvertedToC#\bin\x86\Debug\bin\roslyn\csc.exe</p>
  </blockquote>