Click here to Skip to main content
15,041,548 members
Articles / Desktop Programming / Windows Forms
Posted 12 Jul 2007


77 bookmarked

Embedding Multiple Icons into .NET Executables

Rate me:
Please Sign up or sign in to vote.
4.83/5 (24 votes)
12 Jul 2007CPOL2 min read
A brief walkthrough on how to embed multiple icons (and native resources) into a .NET executable.


I have noticed in various (and lots of) places scattered all across the Internet, requests on how to embed multiple icons into a .NET executable, not embedded in the .NET resources (resx files) but accessible by the Windows Explorer and the like.

After chance comment on a page with nothing to do with the subject at hand, I realised that this capability is built into Visual Studio 2005. This article outlines the procedure required to compile multiple icons into an executable without having to resort to the command-line.

The Process

Step 1: The Resource File

For reasons that shall become apparent later, Visual Studio requires that the icons be compiled into a resource file. It is up to you how you generate this, but I shall use the designers with VS2005.

  1. Create a new "Native Resource Template" from the File | New dialog box.
  2. New Native Resource Template

  3. Right click anywhere in the designer, and select "Add Resource..." to reach the following dialog box:
  4. Import Resources Dialog Box

  5. You can, at this point, import any resources you wish to embed, but we will import some icons, so click "Import..." and select the icon files.
  6. Import File Dialog Box

    If you wish, you can change the ID associated with the resources in the Properties window.

  7. Now, we must save the resource template as a 32-bit Resource File. This is done via File | Save As..., making sure that "32-bit Resource File (*.res)" is selected in the "Save as type" box. Save it somewhere logical, e.g., in your project's directory.
  8. Saving the Resource File

Step 2: Compiling into the Executable

Visual Studio 2005 provides two ways of providing icons for .NET executables. One is via the Application Icon property in the Property pages. The second is via a resource file, and it is this method that we utilise.

  1. Open up the Application tab of the Properties page of your project.
  2. In the "Resources" group box, change the selection to point to Resource File, and browse for the resource file you just saved.
  3. Add Win32 Resource

Step 3: Compiling

Once the previous step has been completed, Visual Studio will now embed the Win32 resource into the executable when it compiles. To see the changes, simply recompile the application.

Multiple Icon Executable

You can see by the above screenshot that multiple icons have been embedded (natively) into the executable. Where this would be useful, for example, is if your application registers a file type, the files can have a different icon associated with them rather than the same as the executable. Or you won't have to distribute an icon file with your program, it can simply be embedded.


Hopefully, that has explained clearly enough how to accomplish the task of embedding multiple icons into a .NET executable without resorting to the command-line. If you have any suggestions for improvements / comments, don't hesitate to post them, I've probably made quite a few spelling mistakes along the way as well (no Intellisense).


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Engineer PooreDesign
United Kingdom United Kingdom
Ed is a student who due to a form of cancer (now clear) took a year out before going to Imperial College, London to study Electronic Engineering.

His interests include shooting (clay-pigeon (shotgun), air-rifle and rifle), playing with his three labradors (Sandy, Rosie and Tundra), programming (most experienced in C# and C, although those are not the only ones), walking (has completed Gold Duke of Edinburgh's Award), playing games and reading.

He lives in two places on a 57 acre farm in West Waleswith the rest of the family during the holidays; and Greater London during term time.

Languages and Technologies: C#, C, VB6, VB.NET, XAML, (X)HTML, CSS, XSLT, Assembler (PIC), ASP.NET, WPF, Windows.Forms, ASP, VBScript, JavaScript, Pascal / Delphi, XML

Current Stuff:
1st Year MEng Electronics Engineering (Imperial College, London)

Comments and Discussions

Questionhow change icon Pin
Member 1036005514-Jun-15 7:58
MemberMember 1036005514-Jun-15 7:58 
SuggestionUsing dll for Icons Pin
coleydog18-Jul-12 16:51
Membercoleydog18-Jul-12 16:51 
QuestionVersion String Pin
Xiaoming Tu25-May-12 6:58
MemberXiaoming Tu25-May-12 6:58 
GeneralMy vote of 5 Pin
Member 820778411-Feb-12 5:14
MemberMember 820778411-Feb-12 5:14 
GeneralIt's amazing! Pin
Member 820778411-Feb-12 5:10
MemberMember 820778411-Feb-12 5:10 
GeneralMy vote of 5 Pin
Mike Rich1-Mar-11 5:11
MemberMike Rich1-Mar-11 5:11 
QuestionHow to do with Visual Basic 2008 express ? Pin
JWD0921-Jul-10 20:44
MemberJWD0921-Jul-10 20:44 
AnswerRe: How to do with Visual Basic 2008 express ? Pin
Ed.Poore24-Jul-10 2:12
MemberEd.Poore24-Jul-10 2:12 
GeneralWarning: This breaks File Properties and msi Upgrades Pin
stevenmcohn2-Mar-10 3:15
Memberstevenmcohn2-Mar-10 3:15 
GeneralRe: Warning: This breaks File Properties and msi Upgrades Pin
Mike Rich1-Mar-11 6:04
MemberMike Rich1-Mar-11 6:04 
GeneralThere is no resources box Pin
rocketman22115-Dec-09 14:08
Memberrocketman22115-Dec-09 14:08 
QuestionGreat... but how to extract them? Pin
J. Elliott5-May-09 11:11
MemberJ. Elliott5-May-09 11:11 
AnswerRe: Great... but how to extract them? Pin
Ed.Poore5-May-09 22:39
MemberEd.Poore5-May-09 22:39 
GeneralRe: Great... but how to extract them? Pin
J. Elliott6-May-09 10:04
MemberJ. Elliott6-May-09 10:04 
GeneralGood Tutorial Pin
ctw3137-Nov-08 23:57
Memberctw3137-Nov-08 23:57 
GeneralRe: Good Tutorial Pin
Ed.Poore8-Nov-08 10:42
MemberEd.Poore8-Nov-08 10:42 
Answerfor Visual Studio 2008 Pin
Nevzat Adagide18-Oct-08 12:58
MemberNevzat Adagide18-Oct-08 12:58 
QuestionRe: for Visual Studio 2008 Pin
Ed.Poore18-Oct-08 20:22
MemberEd.Poore18-Oct-08 20:22 
GeneralImport of .res file not available in VS 2008 Pin
t_anjan11-Feb-08 8:23
Membert_anjan11-Feb-08 8:23 
GeneralRe: Import of .res file not available in VS 2008 Pin
Ed.Poore11-Feb-08 8:50
MemberEd.Poore11-Feb-08 8:50 
GeneralDoes not appear to work with 32-bit icons. Pin
Ineffable1-Aug-07 9:43
MemberIneffable1-Aug-07 9:43 
GeneralRe: Does not appear to work with 32-bit icons. Pin
Ed.Poore1-Aug-07 13:23
MemberEd.Poore1-Aug-07 13:23 
GeneralGood one! Pin
Vasudevan Deepak Kumar12-Jul-07 23:26
MemberVasudevan Deepak Kumar12-Jul-07 23:26 
QuestionCan't add Win32 resource into VB.NET project [modified] Pin
ProJee12-Jul-07 22:34
MemberProJee12-Jul-07 22:34 
AnswerRe: Can't add Win32 resource into VB.NET project Pin
Chris Kolkman13-Jul-07 3:03
MemberChris Kolkman13-Jul-07 3:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.