Adding multiple Icons (Win32-Resource) to .NET-Application

Windows doesn’t know anything about managed resources, you need to add unmanaged resources to your executable. In parapura’s screenshot, you need to select the Resource file radio button. That requires a .res file, a binary file that’s created by running the Windows SDK rc.exe tool on a .rc file. The .rc file is a simple text file that contains resource statements, similar to this:

1 ICON "mainicon.ico"
2 ICON "alternative1.ico"
3 ICON "alternative2.ico"
1 24 "app.manifest"

Be sure to save this file into your project folder without utf-8 encoding, using Notepad is best. Create the required app.manifest file with Project + Add New Item, Application Manifest File. Add this .rc file to your project with Project + Add Existing Item. Double-click it and verify that you can see the icons and the manifest. Right-click the top node, Add Resource and click Version + New. Edit the version info, beware that it will no longer automatically match the attributes in AssemblyInfo.cs

You can compile the .rc file into a .res file with the Visual Studio Command prompt:

rc /r something.rc

Which produces the .res file you can use in the project property tab. Doing this is a pre-build event is advisable but a bit hard to get right. The number of ways this can go wrong are numerous, good luck.

Leave a Comment