title: C# compiler error CS0006: metadata file is not found
body: <p>I've built a c# compiler using the tutorial on MSDN and a few other resources including here, and I've gotten it to work until I add additional reference assemblies. My errors stem from adding "System.dll" and "System.Windows.Forms.dll" to the ReferenceAssemblies list.</p>
  
  <p>here's my code:</p>
  
  <pre><code>private void SetUpCompilingParameters()
      {
          string ver = string.Format("{0}.{1}.{2}", Environment.Version.Major, Environment.Version.MajorRevision, Environment.Version.Build);
          string libDir = string.Format(@"{0}", Environment.CurrentDirectory);
          string raDir = @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0";
          string exWpfDir = string.Format(@"C:\WINDOWS\Microsoft.NET\Framework\v{0}\WPF", ver);
          string exDir = string.Format(@"C:\WINDOWS\Microsoft.NET\Framework\v{0}", ver);            
  
          MyCompiler = new CSharpCodeProvider();
          CompilingParam = new CompilerParameters();
          CompilingParam.GenerateExecutable = false;
          CompilingParam.GenerateInMemory = true;
          CompilingParam.IncludeDebugInformation = false;
          CompilingParam.TreatWarningsAsErrors = false;
          CompilingParam.CompilerOptions = string.Format("/lib:{0}", libDir);
          CompilingParam.CompilerOptions = string.Format("/lib:{0}", raDir);
          CompilingParam.CompilerOptions = string.Format("/lib:{0}", exDir);
          //CompilingParam.CompilerOptions = string.Format("/lib:{0}", exWpfDir);
  
          CompilingParam.ReferencedAssemblies.Add("System.dll");
          CompilingParam.ReferencedAssemblies.Add("System.Windows.Forms.dll");
  
      }
  </code></pre>
  
  <p>As you can see, I've explicitly referenced directories in CompilerOptions but its not helping. I'd like to test the solution on <a href="https://stackoverflow.com/questions/2661127/c-sharp-and-metadata-file-errors/8273526#8273526">here on stackoverflow</a>
  that utilizes: </p>
  
  <pre><code>CompilingParam.ReferencedAssemblies.Add(typeof(System.Xml.Linq.Extensions).Assembly.Location);
  </code></pre>
  
  <p>but I'm having trouble using it for the general System.dll etc...</p>