Changing the WCF service start mode to automatic/manual
Changing the wcf service to start mode or automatic is very easy. In initial stages i used to go to services.msc and change the start mode of my service to automatic or manual, but later on i found that changing the service mode is very easy and it can be done through the code.
First thing you need to do is add the INSTALLER CLASS to the wcf service project then view the code of the installer class.
Then follow the simple steps to make your service to run automatically or manually. The simplest change here is to change the ServiceInstaller.StartType property.
Right this piece of code in the constructor of your installer class.
InitializeComponent();
ServiceProcessInstaller processInstaller = new ServiceProcessInstaller();
ServiceInstaller serviceInstaller = new ServiceInstaller();
//Specifies the type of account that should be used for the WCF service.
processInstaller.Account = ServiceAccount.LocalSystem;
//Specifies the name of the service that is installed.
serviceInstaller.DisplayName = "//Specify the name of your service in the way how it should appear like in the services.msc";
//Gives the description of the Installed service.
serviceInstaller.Description = "Give the description of your service";
//It tells which is the service that is installed.
serviceInstaller.ServiceName = "Specify the name of the service here";
//It specifies the Start type of the service.
serviceInstaller.StartType = ServiceStartMode.Automatic;
Installers.Add(processInstaller);
Installers.Add(serviceInstaller);
So now you are in a great position to change the wcf service start mode.
Hope it helped you ...
Cheers...
Sandeep
Changing the wcf service to start mode or automatic is very easy. In initial stages i used to go to services.msc and change the start mode of my service to automatic or manual, but later on i found that changing the service mode is very easy and it can be done through the code.
First thing you need to do is add the INSTALLER CLASS to the wcf service project then view the code of the installer class.
Then follow the simple steps to make your service to run automatically or manually. The simplest change here is to change the ServiceInstaller.StartType property.
Right this piece of code in the constructor of your installer class.
InitializeComponent();
ServiceProcessInstaller processInstaller = new ServiceProcessInstaller();
ServiceInstaller serviceInstaller = new ServiceInstaller();
//Specifies the type of account that should be used for the WCF service.
processInstaller.Account = ServiceAccount.LocalSystem;
//Specifies the name of the service that is installed.
serviceInstaller.DisplayName = "//Specify the name of your service in the way how it should appear like in the services.msc";
//Gives the description of the Installed service.
serviceInstaller.Description = "Give the description of your service";
//It tells which is the service that is installed.
serviceInstaller.ServiceName = "Specify the name of the service here";
//It specifies the Start type of the service.
serviceInstaller.StartType = ServiceStartMode.Automatic;
Installers.Add(processInstaller);
Installers.Add(serviceInstaller);
So now you are in a great position to change the wcf service start mode.
Hope it helped you ...
Cheers...
Sandeep
No comments:
Post a Comment