C# Windows Service - allow multiple defined services?

A

Adam Clauss

We have a service written in C#. The generated code "hardcodes" the service
name into the exe.

We have a situation where we would like to allow multiple Windows Services
to be defined. These would differ by the command-line parameters passed to
the .exe to give it a different configuration.

Is there a way to do this?
 
A

Anthony Jones

Adam Clauss said:
We have a service written in C#. The generated code "hardcodes" the service
name into the exe.

We have a situation where we would like to allow multiple Windows Services
to be defined. These would differ by the command-line parameters passed to
the .exe to give it a different configuration.

Is there a way to do this?


Surely this is a job for the application config file, especially since its a
service?
 
A

Adam Clauss

I'm not sure I understand -
I can get the application to RUN once it is installed, my problem is the
actual creation of a Windows service.

Install util does not allow you to specify a "service name" to be used for
Windows, so it always uses what is hardcoded into the .exe. Except you
can't have two services with the same name, so the second installutil will
always fail.
 
M

Mr. Arnold

Adam Clauss said:
We have a service written in C#. The generated code "hardcodes" the
service name into the exe.

We have a situation where we would like to allow multiple Windows Services
to be defined. These would differ by the command-line parameters passed
to the .exe to give it a different configuration.

Is there a way to do this?

You can install one .Net NT service that has multiple NT services within the
one installed NT Service.
 
A

Adam Clauss

Mr. Arnold said:
You can install one .Net NT service that has multiple NT services within
the one installed NT Service.

That's the thing, it isn't that there are multiple services within the .exe
itself. They are all doing the exact same action, just possibly with a
slightly different configuration (as passed by command line parameter).

One deployment of the software might need one instance of this process.
Another deployment might need 2, or even 3, etc.
 
M

Mr. Arnold

Adam Clauss said:
That's the thing, it isn't that there are multiple services within the
.exe itself. They are all doing the exact same action, just possibly with
a slightly different configuration (as passed by command line parameter).

One deployment of the software might need one instance of this process.
Another deployment might need 2, or even 3, etc.

This may help you. Idon't know. I am going to keep this link myself, as I
may have a need to do this.

<http://www.c-sharpcorner.com/Upload...M/Passing_parameters_to_Windows_Services.aspx>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top