How to define a property as an Image data type?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a data model that has dozens of properties of most every data type. I
now want to declare a few of these properties as Images but can't seem to do
it.

The approach I thought would work was this one:

private Image _picture;
public Image Picture
{
get
{
return _picture;
}
set
{
_picture = value;
}
}

where I've declared "using System.Drawing" at the top of the file. But it
won't accept it. In fact, Intellisense doesn't even recognize
"System.Drawing".

Is it not possible to declare a property as an Image type?
 
It is, but you need to reference the System.Drawing assembly in your
project. By default DLL project don't reference this. Just right-click on
your project in the IDE, and select Add References, choose System.Drawing
from the list in the first tab, and away you go.
 
Sean,

Unbelievable, thank you! I would have never known to do this. Why
Microsoft couldn't have included some "smarts" into the Visual Studio UI to
account for it is beyond me.

If I'm ever on "Who Wants To Be A Millionaire" and there's a dotNet question
I don't know, I hope I can use you as my lifeline!!!

Thanks again,

Robert
 
Robert W. said:
Unbelievable, thank you! I would have never known to do this. Why
Microsoft couldn't have included some "smarts" into the Visual Studio UI to
account for it is beyond me.

Well, to be fair to them, the error message you should have received is
pretty clear:

"The type or namespace name 'Drawing' does not exist in the class or
namespace 'System' (are you missing an assembly reference?)"

It says what the problem is *and* a possible cause.

Note that a namespace may be contributed to by several assemblies, and
you may also want to use an assembly that VS.NET doesn't know about. I
agree that VS.NET could be better here, but I don't think it's being
particularly bad.
 
Jon Skeet said:
Well, to be fair to them, the error message you should have received is
pretty clear:

I didn't want to say anything, he said such nice things about me :-)
 
Back
Top