I have a .Net app deployed via click-once. The app icon shows fine on the start menu, task bar etc., but not in Add / Remove Programs in the control panel. What do I need to do to fix this? TIA
+1
A:
This isn't supported by ClickOnce (although I keep asking for it).
I collected the following code ages ago, but have never had time to try it out. I'd put a try/catch around it in case it causes a problem. Let me know if it works. ;-)
RegistryKey myUninstallKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall");
string[] mySubKeyNames = myUninstallKey.GetSubKeyNames();
for (int i = 0; i < mySubKeyNames.Length; i++)
{
RegistryKey myKey = myUninstallKey.OpenSubKey(mySubKeyNames , true);
object myValue = myKey.GetValue("DisplayName");
if (myValue != null && (string)myValue == _ApplicationName)
{
myKey.SetValue("DisplayIcon", _ExecutablePath + @"\App.ico");
break;
}
}
RobinDotNet
2010-06-22 02:00:46
This would obviously require you ship with full trust or registry permissions. That is what most ppl do (full trust I mean) but still a good point to remember if you did care about running in lower trust.
ShaneC
2010-06-22 13:59:04
I would think it might work with partial trust because it is editing the HKCU part of the registry, and a ClickOnce app should have access to that.
RobinDotNet
2010-06-22 17:19:17
Where would you put this code - in the app startup code or in some exe post-install (how)?
Graeme
2010-06-23 14:25:39
I would put it in the app startup code. Check ApplicationDeployment.IsNetworkDeployed, if that's true, try this: ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment; if (ad.IsFirstRun) setupicon();That way, it only runs it when the user installs the application or gets an update. Of course, if you can figure out how to do it only the 1st time, that's ideal. (I could do that because we create a cache, and if there's no cache, it's the first time the user has run the app.)
RobinDotNet
2010-06-24 03:56:32
This works fine, though it seems a round-about way of getting an uninstall icon. Hopefully it will be addresssed in some later version of the Click Once technology.Thanks a lot
Graeme
2010-06-24 08:15:58
You're welcome; I'm glad it worked!
RobinDotNet
2010-06-26 03:28:57