title: C# and Metadata File Errors
body: <p>I've created my own little c# compiler using the tutorial on MSDN, and it's not working properly. I get a few errors, then I fix them, then I get new, different errors, then I fix them, etc etc.</p>
  
  <p>The latest error is really confusing me.</p>
  
  <pre><code>---------------------------
  
  ---------------------------
  Line number: 0, Error number: CS0006, 'Metadata file 'System.Linq.dll' could not be found;
  
  
  
  
  ---------------------------
  OK   
  ---------------------------
  </code></pre>
  
  <p>I do not know what this means.</p>
  
  <p>Can somebody please explain what's going on here?</p>
  
  <p>Here is my code.</p>
  
  <p><b>MY SAMPLE C# COMPILER CODE:</b>
  using System;</p>
  
  <pre><code>namespace JTM
  {
      public class CSCompiler
      {
          protected string ot,
              rt,
              ss, es;
  
          protected bool rg, cg;
  
          public string Compile(String se, String fe, String[] rdas, String[] fs, Boolean rn)
          {
              System.CodeDom.Compiler.CodeDomProvider CODEPROV = System.CodeDom.Compiler.CodeDomProvider.CreateProvider("CSharp");
              ot =
                  fe;
  
              System.CodeDom.Compiler.CompilerParameters PARAMS = new System.CodeDom.Compiler.CompilerParameters();
              // Ensure the compiler generates an EXE file, not a DLL.
              PARAMS.GenerateExecutable = true;
              PARAMS.OutputAssembly = ot;
  
              foreach (String ay in rdas)
              {
                  if (ay.Contains(".dll"))
                      PARAMS.ReferencedAssemblies.Add(ay);
                  else
                  {
                      string refd = ay;
                      refd = refd + ".dll";
                      PARAMS.ReferencedAssemblies.Add(refd);
                  }
  
              }
  
              System.CodeDom.Compiler.CompilerResults rs = CODEPROV.CompileAssemblyFromFile(PARAMS, fs);
  
              if (rs.Errors.Count &gt; 0)
              {
                  foreach (System.CodeDom.Compiler.CompilerError COMERR in rs.Errors)
                  {
                      es = es +
                          "Line number: " + COMERR.Line +
                          ", Error number: " + COMERR.ErrorNumber +
                          ", '" + COMERR.ErrorText + ";" +
                          Environment.NewLine + Environment.NewLine;
                  }
              }
              else
              {
                  // Compilation succeeded.
                  es = "Compilation Succeeded.";
  
                  if (rn) System.Diagnostics.Process.Start(ot);
              }
              return es;
          }
      }
  }
  </code></pre>
  
  <p>... And here is the app that passes the code to the above class:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Windows.Forms;
  
  namespace WindowsFormsApplication1
  {
      public partial class Form1 : Form
      {
          public Form1()
          {
              InitializeComponent();
          }
  
          private void button1_Click(object sender, EventArgs e)
          {
              string[] f = { "Form1.cs", "Form1.Designer.cs", "Program.cs" };
              string[] ra = { "System.dll", "System.Windows.Forms.dll", "System.Data.dll", "System.Drawing.dll", "System.Deployment.dll", "System.Xml.dll", "System.Linq.dll" };
              JTS.CSCompiler CSC = new JTS.CSCompiler();
              MessageBox.Show(CSC.Compile(
                  textBox1.Text, @"Test Application.exe", ra, f, false));
          }
      }
  }
  </code></pre>
  
  <p>So, as you can see, all the using directives are there. I don't know what this error means. Any help at all is much appreciated.</p>
  
  <p>Thank you</p>