Application Icon doesn't change correctly using c# - c#

I changed my Application's icon for a new one, by going to: "Project/MyProject Properties/Icon and Manifiest", and load the new icon. Now, in my debug folder the icon of my .exe file appear with the new icon, which is ok, but when I execute the .exe, the application icon in the taskbar still showing the old one.
Please advice.

You have two place to change your icon.
First place
The first place is in the project.
Right click on the project
Select Property
Go in Application Tabs
Choose Icon and Manifest and select the icon you want
Second place
The second place is in the property of your Winform.
Open the Form
Click on the Form
Press F4 or go in the property of the Form
Go down in the property to find "Icon"
Select the icon you want.
The reason you have a different icon in the taskbar than your application (.exe) icon is that the taskbar use the current form icon to display in the taskbar.

After encountering the same problem, I resolved it by doing the following:
Just stop your explorer.exe from task manager and rerun the explorer.exe again.

As a commenter mentioned, you should set in the properties of the *.ico file: Copy to Output Dir: Copy if newer.
This property is not absolutely required. I developed a winform application and tested it without icon. Then I created and added the icon. The icon showed when running with the VS debugger. I copied the bin/debug directory to another pc and there it ran with showing the icon.
But the icon did not show on the development machine when the app started by clicking the *.exe file.
Logout/login windows did not cure this.
Change the Copy To Output Dir property on the icon file to Copy If Newer, and rebuild the application, did help. Now I can start the app by clicking the *.exe and the icon shows nicely.
Conclusion:
It is not always required to build the app with the icon file copied to the output directory, but with this measure you will increase your chances.

Make sure that your *.ico file contains an icon of the proper size (like 16x16 for small task bars).

Copy your new icon in Project Properties --> resources --> icons
In your Main_Load function add:
this.Icon = Properties.Resources.newIcon;

Check this out for icon information and sizes it supports. Assuming this is just a simple error that you are getting check if your ico's are as per what is specified here http://msdn.microsoft.com/en-us/library/ms997636.aspx

I had the same problem and none of the above solved it.
In my case, I had defined the icon different for two different langages (default language english and german). You can see this if there appear two resources files: FormX.resx and FormX.de.resx
With the accepted answer only default icon was changed. But when running the application on my pc the german icon was used.
So I had to change the icon for both resources. In Visual Studio you can change the current resource language by switching the language item (in the forms properties) from default to another language.

I had the same problem. The "first place" mentioned by Patrick is about the file icon, i.e. the .exe aspect. The "second place" is about the form (in the upper left corner).
Restarting windows file explorer seemed to be a satisfactory solution too. But all this didn't work today. I didn't restart the computer, by the way.
This is what really displayed the new icon in the task bar: I realized that there was an old shortcut of the .exe on the desktop. Deleting the shortcut did the job.

Related

Visual Studio Installer Project - shortcut icons not set

I've created a WinForm application with .NET 4.6.1 and C#. I'm using Visual Studio 2017, with latest fixes updated (up to 29-Sept-2018).
The application uses a custom icon, and it's correctly shown: exe file is displayed with the proper icon.
I've created an Installer Project using the "Microsoft Visual Studio 2017 Installer Projects" extension. The installer copies sets of files in different locations (under Program Files, under the user's App Data, etc), and the files are correctly copied. EXE files correctly display the custom icon I've set.
Now, here comes the problem.
I've set a shortcut on the desktop.
The shortcut is created and actually works, but the icon is wrong: the default windows icon is shown instead.
I've tried several solutions and read from several forums.
1- I've tried to "Create New Shortcut" from the File System view (Desktop folder), and then set the Icon from the Properties window.
2- I've tried to right-click the output exe and select "Create a shortcut to primary output", and then dragged the shortcut to the desktop folder.
3- I've tried to select the icon referencing directly the Application Output exe: the wizard allows me to select the correct icon, I select it and confirm.
4- I've tried to select the icon referencing the source ICO file: once again, the wizard allows me to select the correct icon, I select it and confirm.
Any solution I've tried, I ALWAYS obtain a shortcut displayed with the default icon and NOT with the custom icon.
Whatsmore, if I try to manually "Create a shortcut" by right-clicking on the EXE, in window's File Explorer, the shortcut is created using the correct custom icon! So, it's strange that Visual Studio (or the installer) is not able to do the same thing during the installation.
Do you have any idea of the cause of the problem, and how to fix it?
Thanks!
I had the same issue, and tried every combination the OP also tried.
In the end my issue was down to the fact my .ICO file did not have the correctly sized images for the desktop shortcut. (It would have been nice if Visual Studio had told me that!!!!)
Oddly like the OP generating a shortcut by hand did make the icon appear, so I find the above a bit strange!
Anyway I was generating my .ICO file using GIMP to convert a PNG. I had clearly got this stage wrong.
I'd suggest trying a different .ICO file first and see if that is the cause.
It was for me and I solved it by using the following site:
http://icoconvert.com/
I then ticked the relevant boxes for the sizes, used this new .ICO file and hey presto it all works
I'd the same problem.
I had fix it simply select the main ouput (.exe) and not the .ico in the shortcut property icon option. I suppose installer not recognize the .ico file correctly.
I encountered the same problem. Just ensure you set the icon for the project to the same icon file as for the desktop shortcut and user program shortcut.
The icon file must follow the dimensions of Windows 7.
You can use http://icoconvert.com/ for changing the icon dimensions.
I had the same problem, using VS 2019 with the Visual Studio Installer extension.
I checked my icon had the correct dimensions (16x16, 32x32 and 48x48 within the ICO file), so it wasn't this.
Also, I had previously installed the app and the icon had worked fine. I'm using the "replace previous version", but I'm not sure if this is cause.
I double-checked the installers Outputs, and yes, the .ico was being copied/included... however I found that the defined shortcut (in VSI editor) did not have the icon property defined anymore - it had reverted to "(None)".
1
I resolved it in VSI, by using the Properties window for the shortcut, on the Icon property, select Browse from the DDL, then set the .ico from the source file. (The VSI detail tab still shows the default "text doc" icon, but result after install is the one I wanted/selected).
This is not the first time VSI has done this to my projects, so I'm guessing it is a slight bug of this otherwise great extension.
The problem for me was that the .ico was compressed with PNG.
Do not export using Vista PNG compression! Use normal BMP frames instead.

C# Setup Project taskbar search icon is set to default while all other icon are displaying correctly

I created a little project, a setup for the project, and gave the project an icon (from the Application settings in the project properties). Furthermore, I have my setup creating a desktop shortcut and programs menu shortcut. Both shortcuts have the project's icon (selected from the Icon property, chosen by selecting the project, which is the primary output).
Basically everything works perfectly. In all locations the shortcuts and .exe file have the chosen icon, EXCEPT when I search for it from the taskbar.
Search Result
After looking into both of those locations, the bottom one (correct one) is the search result from the desktop shortcut.
The top one (the problem) is located in the start menu programs folder. What I don't understand is that the shortcut in that folder has the correct icon. So the only problem is the search result. Is there any way to change the search result's icon?
Well, I found a work around. Deleted my Setup Project and created an identical one. The first one was more of a learning process, so my only explanation is that perhaps I created the problem without knowing it.
If you have this weird issue, just recreate your Setup Project!

How can i use my debug.exe on another computer with another monitor in fullscreen mode?

The monitor on the first pc was 1280 x 1024. I used WindowState Fullscreen.
Now i tried on another computer, another monitor(less Resolution)
and it's fullscreen, but i can see only a little part of my window.
Update:
Please provide your XAML code and if you changed any window settings in your normal code, share this one as well. Furthermore go to the designer where you can change the layout of our application, click on the window and normally in your bottom right corner is a properties window, go and search through it if you set anywhere a max/min size for the window or any settings referring to the size and its resizing ability. Show me which of these you have set.
It should be enough to set it in XAML as:
WindowState="Maximized
Create your Release Build in Visual Studio this way:
On the Toolbar is the MenuItem "Create" (the 5th from the left side) click on it. Then from the bottom the second one "Create Batch" click it. Then a table opens. There should already be your programm in the version debug. Create a new one, now in release state. Click 'create it'.
Now go open your explorer. Go to the path where Visual Studio saves your projects. Open your current project, then there is a folder with the name of your project, open it as well. Now there is a bunch of files and folder, you are supposed to open the "bin" Folder, then "Release" Folder and in there is an *.exe with the Name of your project. Use this one instead.

Icon on Shortcut to .NET WinForms application automatically update

I have a VB.NET WinForms application which has a custom icon. I changed the icon (to something else) in the project's properties, and I can see it is correct on the EXE that is built, but all shortcut's to it retain the old icon. If I create a new shortcut the icon is correct.
When I try to set the icon on the shortcut manually (using Change Icon in the shortcut's properties) Windows report the error 'The file %1 contains no icons.', which I think may be part of the issue, as it isnt able to locate the icon automatically (so it doesn't update).
What can I do to get the icon on the shortcut to update automatically?
Update: Logging off and on again refreshes the icon cache, and the icons change. Also calling ie4uinit -ClearFontCache updates the icons, but this doesnt work in newer versions of Windows.
Try this.
http://blogs.technet.com/b/heyscriptingguy/archive/2005/08/12/how-can-i-change-the-icon-for-an-existing-shortcut.aspx
I'm not sure why you can't delete the old shortcuts and make new ones, but I hope this helps!

Setting correct icon for Shortcut in VS2010 Setup Project

I have a small app with a setup project.
If I create a shortcut to my Primary Output, then this gets a standard Win7 icon and not the icon specified in my exe's Application Icon?
Whats the best way to make sure my desktop shortcut icon is the same icon as my exe?
e.g. If I change the exe's icon then I'd like the Setup icon to change as well.
If you set the icon for the shortcut you can set a primary output as source. In the file system editor of the setup project, click on the "(Icon)" combobox in the properties pane of the shortcut, then option "(Browse...)", button "Browse...". You'll see this:
Then add output and select the primary output of the exe.
You can add an icon from your target.exe file to the shortcut... in File System On Target Machine, browse to the shortcut in the folder you want to add the icon to (User's Desktop,etc). Right click the shortcut and select Properties Window. You'll see an Icon line... click it, select Browse, then browse to Application Folder/yourExe.exe (change from ICON to Exe files) and say OK. It will show you the icon from yourExe.exe that it has selected, say OK. You basically have to do the same thing for your Add/Remove Icon (appears in Control Panel/Uninstall)... properties page for your setup project. You have to do it for all shortcuts in different folders (User's Desktop, User's Startup, etc.) All icons good now!
To add to Gert's answer: make sure you build your project first. Otherwise the setup app will not see the icon.
Very simple way using IWshShortcut (works in .net 2 too):
WshRuntimeLibrary.IWshShortcut MyShortcut = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(fullPathLnk);
string iconLoc = MyShortcut.IconLocation; // <- example: "c:\icon.ico,0"
I use to check if iconLoc still exists, fix if not, you can use to find and read icon file, etc etc

Categories

Resources