title: 'Rectangle' does not exist in the namespace 'System.Drawing'
body: <p>Using .NET 2.0.</p>
  
  <p><code>System.Drawing</code> is in my References list.</p>
  
  <p>Here is my <code>using</code> statement:</p>
  
  <pre><code>using System.Drawing;
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code>private static Rectangle rScreen;
  </code></pre>
  
  <p>Here is the error on this line:</p>
  
  <blockquote>
    <p>Error Text: The type or namespace name 'Rectangle' does not exist in the namespace 'System.Drawing' (are you missing an assembly reference?)</p>
  </blockquote>
  
  <p>Why?</p>
  
  <p>EDIT: Added compilation code:</p>
  
  <pre><code>Dictionary&lt;string, string&gt; dict = new Dictionary&lt;string, string&gt;();
  dict.Add("CompilerVersion", "v3.5");
  
  CSharpCodeProvider codeProvider = new CSharpCodeProvider(dict);
  
  CompilerParameters parameters = new CompilerParameters();
  
  {
      parameters.ReferencedAssemblies.Add("System.Drawing.dll");
  
      parameters.ReferencedAssemblies.Add("System.dll");
  
      parameters.ReferencedAssemblies.Add("System.Core.dll");
  
      parameters.ReferencedAssemblies.Add("System.Data.dll");
  
      parameters.ReferencedAssemblies.Add("System.Data.Linq.dll");
  
      parameters.ReferencedAssemblies.Add("System.DirectoryServices.dll");
  
      parameters.ReferencedAssemblies.Add("System.Configuration.dll");
  
      parameters.ReferencedAssemblies.Add("System.Web.dll");
  
      parameters.ReferencedAssemblies.Add("System.Xml.dll");
  
      parameters.ReferencedAssemblies.Add("System.Windows.Forms.dll");
  
      parameters.ReferencedAssemblies.Add("System.Web.Services.dll");
  
      parameters.ReferencedAssemblies.Add("System.ServiceModel.dll");
  
      parameters.ReferencedAssemblies.Add("System.IdentityModel.dll");
  
      parameters.ReferencedAssemblies.Add(string.Format(@"{0}{1}Microsoft.ReportViewer.Common.dll", AppDomain.CurrentDomain.RelativeSearchPath, @"\ReportViewer\"));
  
      parameters.ReferencedAssemblies.Add(string.Format(@"{0}{1}Microsoft.ReportViewer.WebForms.dll", AppDomain.CurrentDomain.RelativeSearchPath, @"\ReportViewer\"));
  }
  
  CompilerResults results = codeProvider.CompileAssemblyFromSource(parameters, sources.ToArray());
  
  try
  {
      ApexAssemblyManager.dynamicAssemblies.Add(hashKey, new DynamicAssemlby(results.CompiledAssembly));
  
      return ApexAssemblyManager.dynamicAssemblies[hashKey].CreateInstance(typeName);
  }
  </code></pre>
  
  <p>All other ReferencedAssemblies work and have been working for a long time.  This is the first time I have had such an error.</p>
  
  <p>I have ensured and double checked that the reference is added.  If I try to add it to the project again I get a message that the reference already exists.</p>
  
  <p>Thanks</p>