Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Drawing.Icon doesn't exist

Tags:

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.

like image 776
maxoroka Avatar asked Feb 21 '17 02:02

maxoroka


1 Answers

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

like image 123
Dmihawk Avatar answered Sep 29 '22 21:09

Dmihawk