Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4615892
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:54:17+00:00 2026-05-22T01:54:17+00:00

Using .NET 2.0. System.Drawing is in my References list. Here is my using statement:

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T01:54:18+00:00Added an answer on May 22, 2026 at 1:54 am

    You state in the comments and tags that this is being dynamically compiled by another application. It is therefore likely that this other application is not including System.Drawing.dll as a reference when performing the compilation and therefore, the type is unresolved. It is not enough to merely state using System.Drawing, the assembly defining that namespace and its types must also be passed to the compiler.

    In code, this is done using a CompilerParameters instance passed via one of the CompileAssemblyFrom... calls to the CodeDomProvider instance that is performing the compilation (in this case, the CSharpCodeProvider). The CompilerParameters.ReferencedAssemblies collection indicates to the compiler what assemblies to look at when trying to perform type resolution.

    Update
    Try explicitly adding mscorlib to the references.

    Also, I don’t know if this is related, but as you mentioned a server (is it a service of some kind?), MSDN states:

    Classes within the System.Drawing
    namespace are not supported for use
    within a Windows or ASP.NET service.
    Attempting to use these classes from
    within one of these application types
    may produce unexpected problems, such
    as diminished service performance and
    run-time exceptions. For a supported
    alternative, see Windows Imaging
    Components.

    I’d say this qualifies as an unexpected problem although I wouldn’t expect problems to manifest during a compile process, but rather when executing code. That said, they don’t really specify that in the documentation, so it could apply to the use of System.Drawing.dll as a reference in general.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Json.NET First look at this: using System.Drawing; string json = JsonConvert.SerializeObject(new Rectangle(-3,6,32,32),
My domain model is using System.Net.Uri to represent URLs, and System.Drawing.Color to represent colors.
Here is my code sample... using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using
Using .NET's System.Drawing.Graphics GDI stuff, I have a shape consting of two arrays of
Here is the code... using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls;
We have a piece of code which saves a .Net System.Drawing.Bitmap to file. The
Using the .NET System.ServiceModel.Syndication classes... I would like to add a new SyndicationElementExtension to
Hi I'm using System.Net.Mail to send some HTML formatted emails. What is the correct
using System; using System.IO; using System.Net; using System.Text.RegularExpressions; namespace Working { class Program4 {
I get security exception when using System.Net.WebClient to do HTTP requests, which is due

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.