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 PatelPosted Aug 25, 2016, 8:56 AM
rajeswari gaekwadPosted Aug 25, 2016, 7:45 AM
Tapan PatelPosted Aug 25, 2016, 7:15 AM
rajeswari gaekwadPosted Aug 25, 2016, 3:52 AM
Rajee
Tapan PatelPosted Aug 24, 2016, 10:08 AM
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.