Tim Laughlin's Everything VB.NET Blog


January 2007 - Posts

Embedding an icon into your EXE or DLL

In writing smaller self contained application you may not want to go through effort of utilization a resource file in VB.NET.  Instead you may want to embed your graphical resources directly into your EXE or DLL.

To this is very easy on you have the correct steps.

1. In VS.net add your icon files to your project by dragging and dropping, or adding them via the menus.

2. Once the resource is added Right click on the item and choose Proprerties

3. Set the Build Action to Embedded resource

The resource is now available for use. 

 To get the icon back:

New Icon(System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream("ApplicationNamespace.IconFileName.ico"))

A nice trick for determining the fully qualified name to use when loading resource is to paste the following into the immediate window while running the application in debug mode.

? System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceNames