Multiple Instances of Windows Services

  • Thread starter Thread starter Vlad
  • Start date Start date
V

Vlad

Is there any way to install multiple instances of the same windows service
designed with VS.NET 2003? I tried copying the binaries into a separate
folder and then copying registry entries for the original service under a
new name but the SCM complains that the executable does not have this
service implemented.
Please note that I need to have distinct instances of executables installed
not merely multiple windows services defined within the same exe. - I know
how to do that.

The problem is that I do not know at compile time how many instances of the
service is going to be installed. Also each instance will have a distict
config file with distinct settings. Because config files are bound to the
exe I could not have multiple config files used by the same exe's services
in that scenario.

Thanks!
Vlad
 
Vlad said:
Is there any way to install multiple instances of the same windows service
designed with VS.NET 2003? I tried copying the binaries into a separate
folder and then copying registry entries for the original service under a
new name but the SCM complains that the executable does not have this
service implemented.
Please note that I need to have distinct instances of executables installed
not merely multiple windows services defined within the same exe. - I know
how to do that.

The problem is that I do not know at compile time how many instances of the
service is going to be installed. Also each instance will have a distict
config file with distinct settings. Because config files are bound to the
exe I could not have multiple config files used by the same exe's services
in that scenario.

Yes, you can do this, but it's a nasty hack.

Whatever you want to be different between the instances has to be configured
from a config file. This includes the ServiceName and DisplayName. You'll
probably have other things which need to vary by instance, like port
numbers. Set those to come from the config file as well.

Create separate directories for each instance. Copy all necessary binaries
there, as well as the <service>.exe.config file.

Now, the problem is that if you run installutil on each of these instances,
they will not install. installutil will know nothing about your
<service>.exe.config. In fact, like all other programs, installutil will
only know about installutil.exe.config.

So, you have to copy <service>.exe.config to be installutil.exe.config.

Also, since installutil will only see installutil.exe.config in the
directory it's running from, you'll have to copy installutil.exe to the
instance directory, then run that particular installutil.exe.
 
Thanks for adding on John

That's correct, we need to maintain all the variables between the EXEs in the config file respectively

True, when you run InstallUtil, it will not have access to config file through System.Configuration....so that is why I suggested to load the xml section and read the value and assign it. You will copy the config file in the same folder as the EXE and can use Assembly.Location + ".config" to read the config file.
 
Pari said:
Thanks for adding on John.

That's correct, we need to maintain all the variables between the EXEs in the config file respectively.

True, when you run InstallUtil, it will not have access to config file
through System.Configuration....so that is why I suggested to load the xml
section and read the value and assign it. You will copy the config file in
the same folder as the EXE and can use Assembly.Location + ".config" to read
the config file.

Ok, though that loses you designer support. Also, does that work in an
installer?
 
Back
Top