I have an application that I want to run as a Windows Service. Following instructions provided in this MSDN doc page (I need to host a WCF service, so the procedure also details this part), I can do that, and if I implement the example service it is all right. I use installutil.exe utility and can install and uninstall my application as a Windows Service.
My problem
However I need to install more service of the same application on my local machine. So I need to give them different System.ServiceProcess.ServiceBase.ServiceNames! So consider again the installation code:
[RunInstaller(true)]
public class ProjectInstaller : Installer {
private ServiceProcessInstaller process;
private ServiceInstaller service;
public ProjectInstaller() {
process = new ServiceProcessInstaller();
process.Account = ServiceAccount.LocalSystem;
service = new ServiceInstaller();
service.ServiceName = /* NEED TO PUT HERE THE NAME!!! */;
Installers.Add(process);
Installers.Add(service);
}
}
Is there a way for me to pass the name of the service when calling installutil.exe?
How to approach to this problem? I also tried using the App.Config file and doing something like this:
public ProjectInstaller() {
process = new ServiceProcessInstaller();
process.Account = ServiceAccount.LocalSystem;
service = new ServiceInstaller();
service.ServiceName = System.Configuration.ConfigurationManager.
AppSettings["SrvName"];
Installers.Add(process);
Installers.Add(service);
}
But of course it did not work, this file is called when the application runs!!!