We have many questions on stackoverflow regarding uninstallation of Windows Service.
After trying all of them I still fail to uninstall the windows service on new version Installation.
I use setup and deployment project to install/uninstall my project which has a windows service and some other projects.
During installation of newer version, all other projects are successfully re-installed but windows service project fails to Re-install and says:
Error 1001: The specified service already exists.
I referred this link and tried to add code to my Install custom action to Stop the service. If I understood the answer in this link correctly, I have put the code to stop the service inside projectInstaller.cs file of the Service:
public override void Install(IDictionary stateSaver)
{
ServiceController sc = new ServiceController("SareeManagerNotifications");
if (sc.Status == ServiceControllerStatus.Running)
sc.Stop();
base.Install(stateSaver);
}
Custom action pane looks like:
Where the highlighted part is the Service.
I also went through this answer which says to set custom action condition as NOT PREVIOUSVERSIONSINSTALLED
.
This doesn't work for me. Where am I going wrong ?
Thanks in advance :)