J
Jon
Hi All:
I have created a windows service that creates and monitors a socket
connection between us and a client. I have registered it, and it
works great. The thing is, I would like to have a Windows Service per
client socket connection we monitor. The code is exactly the same,
there are just a few pieces of app.config information that are
different for each Windows Service instance.
So, ideally I would have myservice.exe, and app.config file in
directory ClientA. This would be intalled as Windows Service ClientA.
I would then like to have the same myservice.exe and app.config file
in directory ClientB. This service would be registered as Windows
Service ClientB. That was I could shut down ClientA, and keep ClientB
running etc.
Is there an easy weay to do this (other than creating a separate
installer for each Windows Service instance)? I have tried having the
windows service installer read the ServiceName and DisplayName from
the app.config file, so that I can dynamically install new Client
Window Services as I need them (without having to create a new
installer). The code in my installer would be:
this.serviceInstaller.ServiceName =
System.Configuration.ConfigurationSettings.GetConfig("ServiceName").ToString();
this.serviceInstaller.DisplayName =
System.Configuration.ConfigurationSettings.GetConfig("DisplayName").ToString();
However, I get an error when I try to install the service with the
installutil command. "Object reference not set to an instance of an
object". However the service installs fine if I hardcode the
ServiceName and DisplayName. i.e.
this.serviceInstaller1.ServiceName = "Windows Service ClientA";
this.serviceInstaller1.DisplayName = "Windows Service ClientA";
It appears that the windows service installer has trouble accessing
the app.config file for the ServiceName and DisplayName.
Any thoughts or suggestions on how I can "easily" register the same
windows service exe multiple times on the same Server under a
different windows service name would be most appreciated.
Thanks,
Jon
I have created a windows service that creates and monitors a socket
connection between us and a client. I have registered it, and it
works great. The thing is, I would like to have a Windows Service per
client socket connection we monitor. The code is exactly the same,
there are just a few pieces of app.config information that are
different for each Windows Service instance.
So, ideally I would have myservice.exe, and app.config file in
directory ClientA. This would be intalled as Windows Service ClientA.
I would then like to have the same myservice.exe and app.config file
in directory ClientB. This service would be registered as Windows
Service ClientB. That was I could shut down ClientA, and keep ClientB
running etc.
Is there an easy weay to do this (other than creating a separate
installer for each Windows Service instance)? I have tried having the
windows service installer read the ServiceName and DisplayName from
the app.config file, so that I can dynamically install new Client
Window Services as I need them (without having to create a new
installer). The code in my installer would be:
this.serviceInstaller.ServiceName =
System.Configuration.ConfigurationSettings.GetConfig("ServiceName").ToString();
this.serviceInstaller.DisplayName =
System.Configuration.ConfigurationSettings.GetConfig("DisplayName").ToString();
However, I get an error when I try to install the service with the
installutil command. "Object reference not set to an instance of an
object". However the service installs fine if I hardcode the
ServiceName and DisplayName. i.e.
this.serviceInstaller1.ServiceName = "Windows Service ClientA";
this.serviceInstaller1.DisplayName = "Windows Service ClientA";
It appears that the windows service installer has trouble accessing
the app.config file for the ServiceName and DisplayName.
Any thoughts or suggestions on how I can "easily" register the same
windows service exe multiple times on the same Server under a
different windows service name would be most appreciated.
Thanks,
Jon