3

I have a Icon.ico and in the Properties the Build Action is "Resource"...

I want to load that Icon in the Application..

I did something like this:

Icon theIcon = new Icon(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MyNameSpace.Icon.ico"));

that didnt worked (it says "Value of 'null' is not valid for 'stream'.")

What can I do?

Dave Clemmer
  • 3,777
  • 12
  • 48
  • 72
eMi
  • 5,246
  • 10
  • 58
  • 107

1 Answers1

8

try using Application.GetResourceStream method

using(Stream stream = Application.GetResourceStream(new Uri("/MyNameSpace.ico")).Stream)
{
    Icon myIcon = new System.Drawing.Icon(stream);
}

more information from MSDN

VoteCoffee
  • 3,934
  • 31
  • 39
Damith
  • 60,955
  • 13
  • 99
  • 152
  • Thanks I think that would work also well... I did this: `Stream iconStream = Application.GetResourceStream(new Uri("pack://application:,,,/INBOS_Starter;component/Inbos_Starter_Icon.ico")).Stream;` – eMi Oct 24 '11 at 09:28