Hi, I wonder if anyone can help. I have placed the following in one of my code behind files: Imports System.Drawing Imports System.Drawing.Imaging When I compile I get the following error: Namespace or type 'Drawing' for the imports 'System.Drawing' cannot
be found I don't understand why this is happening. When I import other namespaces I don't have any problems. Do I have to install something else to enable me to use the drawing namespace? I'm totaly lost! cheers
erm.... not even sure what intellisense. I've tried referenceing it manually, but same problem. This is the only namespace I have problems with, really weird.
It can only be about referencing the System.Drawing.dll assembly. Are you absolutely sure, you have it referenced? After you have this assembly referenced, you can import System.Drawing namespace.
I am using VS.NET 2005.
Same problem as described in the begining post.
The fix:
Click on Projects,
Click Add References
under the .NET tab scroll down to System.drawing and select it. Press Add.
Then when you add Imports System.Drawing it will be there.
It would have been nice to see an answer posted for this poor fellow. Rather then these cryptic responses. I for one would like to know why you have to add a reference to get Imports to work. I was under the impression that Imports was basically doing the
same thing as a reference. What is the difference?
For us dummies trying to learn .NET it would be nice if we could get some help and learn this so we can then help those following us as well.
It would have been nice to see an answer posted for this poor fellow. Rather then these cryptic responses. I for one would like to know why you have to add a reference to get Imports to work. I was under the impression that Imports was basically doing the
same thing as a reference. What is the difference?
Difference is that assemblies (the dll files produced by compiling source code, for example the dlls produced by compiling a project in Visual Studio .NET) are the deployable units in .NET. They contain the types you use or create for others (or for use
of your other projects/components by referencing) based on the source code.
Namespaces are logical mechanism to group types, but namespaces can span assemblies. This means in practise multiple dlls files can contain different types which do exist in same namespace. So basically importing is shortcutting to a namespace so that you don't always
need to fully-qualify the type name. For example you can use Color, instead of System.Drawing.Color, when you import System.Drawing namespace. But you can't import it before you have reference to the System.Drawing.dll assembly (before that the full type name cannot
be known)
To add confusion, this also means that namepsaces don't necessarily match dll names. For example you have System.IO.File type, but there is no System.IO.dll in .NET (types in System.IO exist in mscorlib.dll and System.dll. and also in a few other dlls in
.NET 3.5)
Shortly: add a reference to an assembly (/dll) be aware of its contained types, and their namespaces. Add import to have shortcut for these known (referenced) namespaces.
In a recent class we used System.IO and didnt have to reference it.
If I understand you correctly, System.drawing is not used in every project and if you need to use it you have to make sure you have a reference to it. Are only those namespaces that are most common already referenced?
How as a new .net programmer can I find out and learn about when, where and which reference and/or imports I may need?
TheJellyfish
Member
65 Points
13 Posts
System.Drawing Namespace "cannot be found"
Jan 26, 2004 06:07 AM|LINK
Charley Bogw...
Participant
1880 Points
374 Posts
Re: System.Drawing Namespace "cannot be found"
Jan 26, 2004 01:14 PM|LINK
TheJellyfish
Member
65 Points
13 Posts
Re: System.Drawing Namespace "cannot be found"
Jan 26, 2004 04:36 PM|LINK
TheJellyfish
Member
65 Points
13 Posts
Re: System.Drawing Namespace "cannot be found"
Jan 31, 2004 07:17 AM|LINK
joteke
All-Star
46284 Points
6896 Posts
ASPInsiders
MVP
Re: System.Drawing Namespace "cannot be found"
Jan 31, 2004 07:34 AM|LINK
Teemu Keiski
Finland, EU
gp_330
Participant
1446 Points
301 Posts
Re: System.Drawing Namespace "cannot be found"
Feb 12, 2004 04:21 PM|LINK
Vimpyboy
Contributor
3212 Points
651 Posts
MVP
Re: System.Drawing Namespace "cannot be found"
Feb 14, 2004 05:32 PM|LINK
http://weblogs.asp.net/mikaelsoderstrom
http://www.twitter.com/vimpyboy
machrf
Member
8 Points
6 Posts
Re: System.Drawing Namespace "cannot be found"
Apr 15, 2008 06:40 PM|LINK
For any future reference to this article.
I am using VS.NET 2005.
Same problem as described in the begining post.
The fix:
Click on Projects,
Click Add References
under the .NET tab scroll down to System.drawing and select it. Press Add.
Then when you add Imports System.Drawing it will be there.
It would have been nice to see an answer posted for this poor fellow. Rather then these cryptic responses. I for one would like to know why you have to add a reference to get Imports to work. I was under the impression that Imports was basically doing the same thing as a reference. What is the difference?
For us dummies trying to learn .NET it would be nice if we could get some help and learn this so we can then help those following us as well.
joteke
All-Star
46284 Points
6896 Posts
ASPInsiders
MVP
Re: System.Drawing Namespace "cannot be found"
Apr 16, 2008 06:41 PM|LINK
Difference is that assemblies (the dll files produced by compiling source code, for example the dlls produced by compiling a project in Visual Studio .NET) are the deployable units in .NET. They contain the types you use or create for others (or for use of your other projects/components by referencing) based on the source code.
Namespaces are logical mechanism to group types, but namespaces can span assemblies. This means in practise multiple dlls files can contain different types which do exist in same namespace. So basically importing is shortcutting to a namespace so that you don't always need to fully-qualify the type name. For example you can use Color, instead of System.Drawing.Color, when you import System.Drawing namespace. But you can't import it before you have reference to the System.Drawing.dll assembly (before that the full type name cannot be known)
To add confusion, this also means that namepsaces don't necessarily match dll names. For example you have System.IO.File type, but there is no System.IO.dll in .NET (types in System.IO exist in mscorlib.dll and System.dll. and also in a few other dlls in .NET 3.5)
Shortly: add a reference to an assembly (/dll) be aware of its contained types, and their namespaces. Add import to have shortcut for these known (referenced) namespaces.
Teemu Keiski
Finland, EU
machrf
Member
8 Points
6 Posts
Re: System.Drawing Namespace "cannot be found"
Apr 16, 2008 11:22 PM|LINK
In a recent class we used System.IO and didnt have to reference it.
If I understand you correctly, System.drawing is not used in every project and if you need to use it you have to make sure you have a reference to it. Are only those namespaces that are most common already referenced?
How as a new .net programmer can I find out and learn about when, where and which reference and/or imports I may need?
Thank You for the informative reply.