5
Answers

Windows Service code change not updating in the new build

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
  1. private void ProjectInstaller_BeforeInstall(object sender, System.Configuration.Install.InstallEventArgs e)  
  2.        {  
  3.            List<ServiceController> services = new List<ServiceController>(ServiceController.GetServices());  
  4.   
  5.            foreach (ServiceController s in services)  
  6.            {  
  7.                if (s.ServiceName == this.serviceInstaller1.ServiceName)  
  8.                {  
  9.                    ServiceInstaller ServiceInstallerObj = new ServiceInstaller();  
  10.                    ServiceInstallerObj.Context = new System.Configuration.Install.InstallContext();  
  11.                    ServiceInstallerObj.Context = Context;  
  12.                    ServiceInstallerObj.ServiceName = "SARWindowsService";  
  13.                    ServiceInstallerObj.Uninstall(null);  
  14.   
  15.                    break;  
  16.                }  
  17.            }  
  18.        }  
 Now it do uninstall the service before installing the new build but the problem is
the code change i make doesnot reflect in the new build.
 
Can anyone help on this
 
Thanks 
 
 
Answers (5)