Using .NET 2.0.
System.Drawing
is in my References list.
Here is my using
statement:
using System.Drawing;
Here is the code:
private static Rectangle rScreen;
Here is the error on this line:
Error Text: The type or namespace name 'Rectangle' does not exist in the namespace 'System.Drawing' (are you missing an assembly reference?)
Why?
EDIT: Added compilation code:
Dictionary<string, string> dict = new Dictionary<string, string>();
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);
}
All other ReferencedAssemblies work and have been working for a long time. This is the first time I have had such an error.
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.
Thanks