Include icons in .net exe file

Posted on 2008-01-26
Medium Priority
Last Modified: 2013-12-17
I am trying to include icons in my .net exe so that I can select those icons for the shell, like setting the icons of shortcuts, icons for some file types, etc...

I tried to include the icons in the Resource files, with different 'Persistance' property set, added icons directly to the solutions with different 'Build Action' property set.

But the only icon that appears in the exe file, when I try to select an icon through the windows explorer is the one that I selected for the application from the project properties.

Please advice.

Question by:ashutosh_kumar
  • 3
  • 2
LVL 12

Assisted Solution

ShazbotOK earned 80 total points
ID: 20755188
You can add images as a embedded resource by going to Project properties --> Resources --> Add --> Existing File.

Once added you can reference the image under the Resources namespace.

Author Comment

ID: 20761168
shazbotOK, I understand what you are saying. But thats now what I want.

Actually, I got my answer from the Microsoft's forum....

MCTS - .net 2.0 Win Apps

Accepted Solution

ashutosh_kumar earned 0 total points
ID: 20761195
The solution

   You have to place the icons in a Win32 resource file (you create it with the Resource Compiler).  You then have to modify the CSPROJ file to include the /win32res flag on the CSC task to point to your Win32 resource file (through the Win32Resource attribute) or you can manually compile your project on the command line and use this flag.

   If you want to specify an icon for your assembly, then you have to use the /win32icon switch, and point to a icon file.

   The documentation for CSC (the executable and task in MSBUILD) has more information.

- Nicholas Paldino [.NET/C# MVP]
Hi Nicholas,
Thanks for your response.

I have created a resource file in Visual C++ 6.0 editor and have also
compiled it to .res file. However, I don't want to compile the project from
the command line every time. So, can you please assist me where should I put
the 'win32res' flag as C# doesn't provide a GUI as C++ to change/add
compiler options.



Hi Ashutosh,

If you're using VS 2005, you can embed the Win32 resource file in the C#
project through the Project Designer.

In detail:
1. Right click the project item in the Solution Explorer and choose
2. In the Project Designer, switch to the Application tab.
3. Select the option 'Resource File' in the Resources group and click the
button on the right to browse to your Win32 resource file.

Hope this helps.
If you have any question, please feel free to let me know.

Linda Liu
Microsoft Online Community Support
LVL 12

Expert Comment

ID: 20768346
Soooo... am I to understand that you want to basically allow your Userbase to be able to change the Icon's within the display of the application?  as in simply referencing a image NOT compiled within the EXE/DLL ??

Author Comment

ID: 20768718
No, I wanted windows shell (explorer) to access icons in the exe, other than the one that is displayed as the exe's icons.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
The PowerShell Core 6.0 of .NET release is just the beginning. The upcoming PowerShell Core 6.1 would have artificial intelligence and internet of things capabilities. So many things to look forward to in the upcoming release.
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
To export Lotus Notes to Outlook PST or Exchange and Domino Server files to Exchange Server or PST files with ease, go for Kernel for Lotus Notes to Outlook conversion tool. Through the video, you can watch the conversion process. A common user with…

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question