I would like to change taskbar icon to identity what type the current app is, so I set a default icon for the app and the icon will be changed according to the type returned from server when the app is launching.
I just change the icon like this:
Application.Current.MainWindow.Icon = new BitmapImage(new Uri(string.Format("AppLogos/{0}.ico", terminal.TerminalType.Name), UriKind.Relative));
It's working well on Visual Studio but I found out that it's not changing my task bar on deployed app (Install the app using a MSI file).
So is there a way to do it?
UPDATE
To force the icon refresh on my deployed app I have to pin/unpin my icon taskbar, unfortunately this is a user command only so I can't do this in wpf programmatically.
@563203132 Maybe you forget to package the AppLogos files.
@lindexi Thank you for your reply. I’m totally sure these files have been packaged in because the top-left attached icon has been changed.
@563203132 Could you upload a mini repo?
Thanks, @563203132. We need a test project to investigate further.
Hi @lindexi , @ryalanms , please try the following test project.
Source Code: Demo.zip
Installer: Demo_Installer.zip
It's working well on Visual Studio:


but it doesn't work on the deployed app:


@ryalanms , @lindexi , any updates? or anything else do you need me to provide?
@563203132
Hello, I try to copy all the files released by your msi to the D disk and find that you can replace the icon normally, not anywhere on the C disk, you can try to add administrator rights to your application, then package and try
@563203132 This issue appears to be a file permission issue. Thank you @musli
Try putting the program in a folder that normal permissions can access, such as a D: drive
Translation:
看起来是文件权限的问题,@musli 尝试将 msi 安装完成后的内容拷贝出来放在 D 盘,此时可以正常运行,显示符合预期的图标
细节请加群 714704041

Hi @musli , @lindexi , thanks, I tried to just copy the build package before, but it's still not working to install the app to D disk even though running it with administrator permission, it doesn't seem to be a permission problem, the icon can't be changed as long as running it in the install folder.
@563203132 @lindexi After many experiments, the icon of the taskbar is always equal to the icon of the startup file, such as changing the icon of the shortcut to the program to a tiger, then the icon of the taskbar where the program runs will also be a tiger.

@musli , It seems not, the taskbar icon will be changed when I pin/unpin the taskbar.



Seems there is a cache, but I don't know how to refresh it programmatically.
@563203132
@musli , Thanks, but I would like to build an All-In-One terminal, that says there are some terminal types, I can config the type of a terminal dynamically in the server(it means a terminal can be an email app or a browser app at different moments, that's controlled completely in the server.), and the taskbar icon can be changed accordingly to identify what type the terminal is when the terminal is launching, so the shortcut of the terminal is just a default icon, only when the terminal is launching does it know what icon should be displayed.
@563203132 I found an interesting thing
1.The taskbar of "Demo.exe" released by msi does not change as the icon of the form changes
@musli , thanks for you help, and I believe there must be a normal way can be solve it unless it's a underlying bug.