none
Windows 7 task bar icon not displayed correctly

    Question

  • Hi,

    I am writing a Windows Forms application in C#. I assigned an icon, a 32x32 one, to the main form. When I run this application by pressing "F5" on Visual Studio, or double-click the executable, the application icon at bottom of the screen shows my icon correctly.

    However, after I build a msi using Visual Studio setup, and run this msi and install the application, when it runs, the application icon at the bottom of the screen no longer shows my icon - it shows the Visual Studio default icon.

    What went wrong?

    Thanks!

    Friday, June 08, 2012 5:25 AM

All replies

  • Have you included your icon in the project?

    I guess not. You have to add it "manually". Check here how its done: http://social.msdn.microsoft.com/Forums/eu/winformssetup/thread/e0ac908d-8c33-4d99-88dd-d8d8be77d198

    Or right click on your project name and choose Properites. Then in applicaiton tab look for Resources groupBox and Icon and manifest radioButton. Look for your icon and set it.


    Mitja


    Friday, June 08, 2012 5:30 AM
  • I see two possibilities here.

    1. You used some hard-coded path to the icon (and not internal resource/ImageList)

    .i.e.

    Say your Solution Folder hierarchy is MyIconProject\MyIconProject\Resources\AppIcon.png

    in your Code you write something like:

    string iconPath = string.Format("{0}\{1}", Path.GetFullPath("."), @"../../MyIconProject/MyIconProject/Resources/AppIcon.png");

    we do ../../ to come out 2 levels as Application Execution path is (from Visual Studio) ~\bin\debug\

    if you did it this way then... while creating msi you have to make sure the Folder hierarchy is maintained as a Pre-Install condition.

    2. If everything else is fine, the verify you didnt miss bundling the icon file along with application exe etc.


    .NET Maniac -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

    Friday, June 08, 2012 5:35 AM
  • No I didn't explicitly do that. How do I bundle the icon file along with the application exe?
    Friday, June 08, 2012 5:38 AM
  • When you use the Wizard to create Deployment package... just add the icon file into the Folder. (Right Click > Add Files) something as simple as that.

    .NET Maniac -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

    Friday, June 08, 2012 5:40 AM
  • Just to make sure we are on the same page: when my application starts, an icon is shown at the bottom of my Windows 7 screen - Windows 7 does this for every forms application. It is on this icon that the correct image wasn't displayed.

    I just bundled the icon file into the msi, and I checked that this icon file is indeed in the application folder, together with the exe. I then added the following code in the form's on-load event handler:

                string strIconFilePath = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) +
                    "\\my_icon.ico";
                Icon = new Icon(strIconFilePath);

    After installation it still doesn't work.

    Is it possible it is because the size of the icon (32x32) is not liked by Windows 7?


    • Edited by Silan Liu Friday, June 08, 2012 6:03 AM
    Friday, June 08, 2012 6:02 AM
  • Hi silly_dude,

      Do you obey the walkthrough to deploy your image resource? The follow two threads I think you can read it ,perhaps it could help you resolve your problem.

       Setup project, custom icon

      http://www.dreamincode.net/forums/topic/263217-setup-project-custom-icon/ 

      Have you resized your image to random size not the 32*32 size or 16*16 size? Here is its steps mentioned by above link.

     
    1) Right clicked "properties" in solution explorer
    2) Select "Open"
    3) Selected resource tab
    4) Add Resource -> add new icon.
    5) Open MS Paint with the image you want as an icon.
    6) Resize image so its 94x94 or 32x32 etc (see bottom right of MS Paint). (i think it has to be a bitmap but im not 100% sure)
    7) Copy Image.
    8) Right click below 32x32 and selected "new image type".
    9) Selected the appropriate size, and then pasted in the resized image from paint.
    10) Save.
    11) Return to the Solution explorer window.
    12) Select the setup file and then clicked the File System Editor icon at the top of the Solution Explorer window.
    13) Select Application Folder on the far left.
    14) Select "Primary Output".
    15) Right click and select "Create Shortcut for...".
    16) Select the new Shortcut.
    17) Properties Window, click on "Icon" and browse through the folders till you find where you saved the icon.
    18) Build solution.

      Hope it helps you.

      Sincerely,

      Jason Wang


    Jason Wang [MSFT]
    MSDN Community Support | Feedback to us

    Monday, June 11, 2012 5:05 AM
  • Hi, that doesn't seem to be my problem. My problem is that it everything works fine when I run the application from visual studio by clicking "F5". But once I build a msi installation then install from there, my own icon was replaced by the default icon on the task bar.
    Wednesday, June 13, 2012 2:53 AM
  • Hi silly_dude,

      I feel you could follow Mitja Bonca's suggestions. Its link has perfect explanations.http://social.msdn.microsoft.com/Forums/eu/winformssetup/thread/e0ac908d-8c33-4d99-88dd-d8d8be77d198 

      Have you tried it?

      Sincerely,

      Jason Wang

     


    Jason Wang [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, June 13, 2012 7:44 AM
  • No that's different from my scenario. He's talking about creating a shortcut, while my problem is that my own icon is not displayed on the square on the Windows 7 task bar.
    Wednesday, June 13, 2012 8:05 AM