12

I am working on a first time C# project in Visual Studio 2005 and I am wondering if there is anything special that needs doing to change the application icon apart from changing the correct resource in the project properties.

I manage to view the new icon displayed in Explorer, but the icon in the application, the tray, and the task bar stays as the old icon.

I am wondering if this has anything to do with Windows Vista perhaps caching the applications icon and from then on not really refreshing it. The same happens in Explorer if you have thumbnails turned on.

If it does indeed cache the icon, what can I do to update/delete the cache, and also what is it based on (GUID perhaps? Not file name though as I changed that and still the same).

Thanks

mr-euro
  • 2,732
  • 5
  • 23
  • 27
  • I tried in another computer where the app never ran before and still the same issue, so caching discarded. – mr-euro Sep 22 '09 at 14:33

6 Answers6

13

It has probably nothing to do with Vista. Following shots shows a Windows Form Apploication runnig on Vista. You may have tried same template but using .Net Framwork 2.0. I am not sure but i think .Net Framework 3.0 was not available with VS 2005. You need to set the Forms Icon property.

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
Asad
  • 21,468
  • 17
  • 69
  • 94
  • Thanks asdi, this is exactly what I ended up doing. I finally located the icon inside the Properties of the actual form and not the solution. – mr-euro Sep 22 '09 at 20:20
  • so why have you accepted another answer? I had the same problem today and Asad's answer is the most helpful. – shift66 Feb 03 '12 at 21:15
11

Have you tried setting a Form.Icon (Winforms) or Window.Icon (WPF)?

dtb
  • 213,145
  • 36
  • 401
  • 431
  • 1
    No, but currently the old icon displays fine. I am trying to replace the old icon with a new one by simply editing it inside the Visual Studio Icon Editor. It does not change all icons though only the one associated to the application. – mr-euro Sep 22 '09 at 14:48
  • 4
    When you assign an icon to the `Form.Icon` property in Visual Studio, the IDE doesn't make a reference to the file you're adding but copies the file into the `.resx` file associated with the form. To update the icon you have to assign the icon again so Visual Studio updates the copy. – dtb Sep 22 '09 at 14:54
  • Cheers dtb, it seems that s where I was going wrong. I located the resx file in question and saw a few images corresponding to each tab in the application. Although when trying to edit/re-import them I get a warning. Still investigating. Thx. – mr-euro Sep 22 '09 at 15:07
  • Only missing the tray-bar icon now. Can't seem to find where to change it. – mr-euro Sep 22 '09 at 15:55
  • done! thx for the hint about re-importing the icons into the resx. – mr-euro Sep 22 '09 at 16:31
1

Additional tray icon from resources. Put an appropriate image into the resources and name it icon.

NotifyIcon tray = new NotifyIcon();
tray.Icon = Icon.FromHandle(WindowsApplication1.Properties.Resources.icon.GetHicon());
tray.Visible = true;
Bitterblue
  • 13,162
  • 17
  • 86
  • 124
  • Even in Visual Studio 2013, with the ICON property set, the app *still* doesn't show the icon in the task bar until you do this. – Redgum Sep 03 '14 at 20:28
1

I had the exact same problem when I wanted to create an icon for my WinForms program. The following solution worked for me:

Start creating an icon in i.e. Paint or Photoshop. Make the size preferably 256x256 and 24 bit color. If you use 32 bit color, you won't be able to make the background transparent. Save your image as .png.

Use your favourite internet browser and enter the page http://iconverticons.com/online/

This page converts your .png into an .ico-file. Since you had an 256x256 input file, the web application is able to create an .ico-file with sizes from 256, 128, 64, 32, 24 and 16 squared.

This icon can then be added to your project by right-clicking your projects name in solution explorer -> Properties -> Application. Under the Resources-field, choose Icon and manifest, and press the three dotted button to the right for the icon-combo box. Browse to your icon-file and choose it.

This will add the icon to your project as you can see when using windows explorer. Note that you have to copy the .exe file from your bin-directory into another directory in order to see the change of icons. This is because the thumbnail icons are not refreshed so easily.

This will, however, not add the icon to your task bar. In order to do that, go to your Form design window, that is where you can change the graphical appearance of your program. Go to properties and choose "Form1" in the combo box. There you will find an option called Icon. By browsing this property to your .ico-file, you can add the icon file to your program and it will appear on the task bar as well.

I hope this works for all of you who wants to add an icon to your project. I will add some descriptive images once I get enough rep.points to enable that :-|

Trident
  • 31
  • 5
0

The Icon in tray, and the task bar is based on the Form or Window Icon. The application Icon (the one you see in explorer) is set in the properties.

Kris Erickson
  • 33,454
  • 26
  • 120
  • 175
  • 1
    The part I am missing then is how does the old icon gets displayed still when I simply have edited the old icon and overwritten it (creating the new icon). Confused... – mr-euro Sep 22 '09 at 14:51
0

I've just suffered from the same problem, 8 years on. It does appear that Windows (7) or Visual Studio (2017) is caching the icon. The only way I can find to clear this cache is with a power cycle.

iChal
  • 85
  • 1
  • 6