45

I am working on a Wpf desktop application, whenever i run my application it shows me a window and associated tab in the task bar(Normal windows feature). My problem is that the tab is using window's icon for unknown file-type, I tried with Icon property of Window, Icon gets assigned but still problem is when I run application, task bar Tab initially displays window's icon for unknown file-type and when window-load completes it changes to the Icon assigned. I want Icon there from beginning. Any help?

Edit:

I tried with .csproj --> Properties --> Application Tab --> Icon and set it to a .ico file. It works but I need to run my application by .exe file. It doesn't work in development environment(while running through visual studio). I need to set Start-Project option then. Is there any other way to solve this problem?

Community
  • 1
  • 1
viky
  • 16,233
  • 13
  • 65
  • 88
  • I encountered a similar issue. When running my debug build on WIndows 7 32-bit the application icon was not displayed in the task bar (a default icon was used). This was not an issue on Windows 7 64-bit or with the release build on either Windows 7 32-bit or 64-bit. This was with .NET 4.5 and VS2013. – denver Feb 23 '15 at 21:34

6 Answers6

55

Check the properties of your main Window project.. You should be able to set an icon there.

Setting an icon on your project

Update: Is it such a problem that your icon does not show in debug mode? As long as it works when you deliver the program to your customer, its all alright, not?

On a side note: You could check some things though. Perhaps your icon is not included in your project, or it isnt copied when building to your Debug folder?

Update 2: You also need to set the Main Form's Icon for it to show in Debug. If you also set the icon for the main form, it will display in the Taskbar during Debug / Runtime.

Community
  • 1
  • 1
Arcturus
  • 25,273
  • 10
  • 88
  • 101
  • thanks for the responce, but it works only when I run my application by .exe file. But when I run it in visual studio it doesn't work. I have updated my question for that. – viky Jun 07 '10 at 14:48
  • 19
    If it's really bothering you go to the Debug tab in the project settings and uncheck "Enable the Visual Studio hosting process". This will debug against the app directly instead of using the intermediate vshost.exe file. – John Bowen Jun 08 '10 at 01:57
  • 1
    Is this fixed in VS 2012+? I spent more time that I should have trying to diagnose my app's taskbar icon. – Gary Kindel Nov 09 '13 at 13:19
  • 1
    Could you please update your answer to include a note about setting the icon on the Main form. That was what I missed as well at RooiWillie (below) – Simon Parker Mar 13 '15 at 06:28
  • 1
    ..so what's the **"Main Form"** for a WPF app?? – cacau May 28 '15 at 06:57
  • @cacau In WPF that would be the main window and the [Window.Icon](https://msdn.microsoft.com/en-us/library/system.windows.window.icon%28v=vs.110%29.aspx) property – Roman Reiner Mar 03 '16 at 08:44
43

I had a similar issue and google led me to this article. I forgot one simple thing, and that was my Main Form's Icon. If you also set the icon for the main form, it will display in the Taskbar during Debug / Runtime.

RooiWillie
  • 2,009
  • 1
  • 27
  • 34
30

For WPF applications, use the attribute

Icon="Images\Logo.ico"

for the Window element in XAML to have the window show the icon.

MrKos
  • 1,490
  • 2
  • 15
  • 17
  • 1
    quick and clean. this should be the best answer. – Doc Jul 06 '15 at 09:28
  • 1
    @Doc There are multiple points where you define icons for different purposes... the window icon (of the main window as shown in the task bar => the Icon="Images\Logo.ico" solution above) does not set the icon of the compiled executable (like the accepted solution of Arcturus does). Both are solutions for different things and none of these does replace the other. So there is no "best" if they have different behavior. – Beachwalker Aug 01 '16 at 14:00
  • worked fine, I didn't notice that it was set before in my xaml so when I was setting the icon in the project it wouldn't show cause it was override by this line – Marcos Brinner pikatoons Mar 20 '18 at 18:25
5

I know this is old, but I found that I could get the icon to show in the taskbar in Debug mode if I went to the project's properties and checked the "Enable native code debugging" box on the "Debug" page

riqitang
  • 2,812
  • 3
  • 27
  • 44
0

That worked for me. In a VB application, go to Debug screen of Project options (of the UI project) and select Enable unmanaged code debugging. Not sure if there are any negative side effects, but it sure showed the icon during debug. Thanks.

Dan G.
  • 369
  • 2
  • 15
  • 2
    Looks like there is an unacceptable side affect: You can't edit code in debug mode. I'm guessing everyone knew that except me. Now I know. – Dan G. Feb 02 '14 at 00:05
0

This is old but you can also change the shortcut icon in the setup projet, this is what worked for me (when viewing file system by right clicking the setup project).

PmanAce
  • 3,455
  • 2
  • 19
  • 27