fertjungle.blogg.se

Multimc instance.cfg
Multimc instance.cfg





multimc instance.cfg
  1. Multimc instance.cfg how to#
  2. Multimc instance.cfg install#
  3. Multimc instance.cfg code#
  4. Multimc instance.cfg windows#
multimc instance.cfg

Adding a new instance of the service becomes as simple as a copy/paste of the service installation directory and change of some configuration values.

Multimc instance.cfg install#

Now all that is left to do is install this service at a few different locations on the same machine.

Multimc instance.cfg windows#

Using the Location property of the Assembly, we can identify the installation path of the Windows Service and open that services configuration file as shown below. The easiest and most reliable way I found to do this is to use the Assembly class in the System.Reflection namespace. So, we need to find another way to access the configuration file for our service. The reason why it's more difficult during installation is the fact that InstallUtil which is used to install the service does not run in the same execution path your service does, instead it runs at :\windows\Microsoft.NET\Framework\v7\. It is a little trickier during installation. This is cake while the service is running because the configuration file loaded into the configuration system will be the configuration file for your service. The app.config file needs to be accessible during the installation of the service as well as when the service starts up. Reading the Service Name from Configuration Someone installing the service could mistype the servicename they provide during install which wouldn't match the value set in configuration. The reason I chose not to recommend this option is that it does not allow us to reliably set the ServiceBase.ServiceName to the exact value that was provided during installation. Then that would allow us to pull the servicename property off the Context.Parameters collection during installation. An app.config file needs to be added to your solution if one doesn't already exist to store the unique service name in order to dynamically set the ServiceInstaller.ServiceName and the ServiceBase.ServiceName to the same service name value you added to your configuration.Īlternately, we could have provided a custom command line switch to the InstallUtil during installation like InstallUtil /i /servicename="Service Instance 1" MultipleInstanceService.exe. The cleanest and most readily available way of providing the service name is to use an app.config file for your service and create an appSettings key that can be read from to set the service name. This will be facilitated using the app.config file. Finally, you need to be able to set the service name dynamically during installation and startup. Then you need to have copies of installation directories for each service instance you'd like to have. The SolutionĪll that needs to be done is to make sure that the name of each service installation instance is unique. To get around this, all that needs to be done is to dynamically set the service name during installation and service startup to a known value and to make sure that value is different for each instance of the service you install. You can view the complete documentation on the CreateService function here.

multimc instance.cfg

This is what causes the Win32Exception to be thrown in the above window and ultimately causes the second install to fail.

Multimc instance.cfg code#

CreateService will return the ERROR_DUPLICATE_SERVICE_NAME return code whenever the method is called with a serviceName or displayName parameter that matches that of an already installed service. When reviewing the ServiceInstaller class using Reflector, you'll see it does a Win32 call to CreateService in the ServiceInstaller.Install method. If you have a need to install multiple instances of the same service, then please read on. When attempting to install a second instance of a service using InstallUtil on the same machine, you'll likely be presented with the following message:įortunately, there is a way around this. At first glance, it seems like it's not supported by the operating system.

Multimc instance.cfg how to#

It's not readily apparent how to install a Windows Service multiple times on a single machine.







Multimc instance.cfg