Hi,
I am having a windows service where I am programatically uninstalling it if previous version exists and installing the service.
The code to uninstall as below
- private void ProjectInstaller_BeforeInstall(object sender, System.Configuration.Install.InstallEventArgs e)
- {
- List
services = new List (ServiceController.GetServices()); - foreach (ServiceController s in services)
- {
- if (s.ServiceName == this.serviceInstaller1.ServiceName)
- {
- ServiceInstaller ServiceInstallerObj = new ServiceInstaller();
- ServiceInstallerObj.Context = new System.Configuration.Install.InstallContext();
- ServiceInstallerObj.Context = Context;
- ServiceInstallerObj.ServiceName = "SARWindowsService";
- ServiceInstallerObj.Uninstall(null);
- break;
- }
- }
- }
the code change i make doesnot reflect in the new build.
Can anyone help on this
Thanks

Tapan PatelRank #614 · 3.9K reputationPosted Aug 24, 2016, 6:08 AM EDT
Just try stopping the service before doing uninstall and to make your code more concrete, try to wrap uninstall code in Try/Catch block. that would help to find an issue if any.
rajeswari gaekwad52 reputationPosted Aug 24, 2016, 11:52 PM EDT
Rajee
Tapan PatelRank #614 · 3.9K reputationPosted Aug 25, 2016, 3:15 AM EDT
rajeswari gaekwad52 reputationPosted Aug 25, 2016, 3:45 AM EDT
Tapan PatelRank #614 · 3.9K reputationPosted Aug 25, 2016, 4:56 AM EDT