maxoroka
maxoroka

Reputation: 53

System.Drawing.Icon doesn't exist

I am trying to create an icon from a stream like this for example:

System.IO.Stream iconStream = Application.GetResourceStream(new Uri("pack://application:,,,/YourReferencedAssembly;component/YourPossibleSubFolder/YourResourceFile.ico")).Stream;

Then when I try to assign it like this it has no notion of Icon inside Drawing, I tried adding the reference and still nothing:

tbi.Icon = new System.Drawing.Icon(iconStream);

Having this at the top:

using System.Drawing;

Here's the error:

Error 1 The type or namespace name 'Icon' does not exist in the namespace 'System.Drawing' (are you missing an assembly reference?)

Its really puzzling to me, I'd appreciate any ideas on what simple thing I must have forgot to add.

Upvotes: 5

Views: 4075

Answers (1)

Dmihawk
Dmihawk

Reputation: 599

It's likely that your project isn't referencing that assembly.

To fix it:

  1. Go to your project references
  2. Right click and select "Add Reference..."
  3. Under Assemblies, select "System.Drawing"

I'm hoping that should take care of it

Upvotes: 5

Related Questions