Load an Icon from an Embedded Resource in .NET
When you are developing a Windows Forms application in .NET, it’s not immediately obvious how to programatically load an icon file embedded in your executable. This recipe shows you the 1 line solution.
Your icon file should be a regular windows icon file. Add it to your project, and in the properties for the icon make sure that it is set to Embedded Resource.
Now in your code, add the following line:
Icon theIcon = new Icon(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MyNameSpace.Filename.ico"));
Replace “MyNameSpace” with the namespace of your application, and replace “Filename” with the name of your icon file.
You should now be able to use the icon directly in any windows control that uses icons, like the NotifyIcon control.








Kaminda said on May 24, 2009
G8 Thanks, It saved me very valuble time. Cheers
Hossrod said on June 30, 2010
I ran into one hiccup that took me a while to figure out, but if the icons are in a sub-folder, you need to include the name in the namespace.
For example, if Filename.ico was in a folder called Icons, it would be reffrenced as “MyNameSpace.Icons.Filename.ico”.
Tom said on September 14, 2010
Icon ico = Properties.Resources.ICONNAME;
8P