473,738 Members | 3,636 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# Windows Service - allow multiple defined services?

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?

--
Adam Clauss

Jan 8 '08 #1
6 2089
"Adam Clauss" <ca*****@tamu.e duwrote in message
news:13******** *****@corp.supe rnews.com...
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?

--
Anthony Jones - MVP ASP/ASP.NET
Jan 8 '08 #2
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.

--
Adam Clauss

"Anthony Jones" <An*@yadayadaya da.comwrote in message
news:uA******** ******@TK2MSFTN GP04.phx.gbl...
"Adam Clauss" <ca*****@tamu.e duwrote in message
news:13******** *****@corp.supe rnews.com...
>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?

--
Anthony Jones - MVP ASP/ASP.NET


Jan 8 '08 #3
Peter has figured this one out well.

http://www.eggheadcafe.com/articles/20041204.asp
Concentrate on the IService interface, and not the msmq stuff.


"Adam Clauss" <ca*****@tamu.e duwrote in message
news:13******** *****@corp.supe rnews.com...
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?

--
Adam Clauss

Jan 8 '08 #4

"Adam Clauss" <ca*****@tamu.e duwrote in message
news:13******** *****@corp.supe rnews.com...
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.
Jan 8 '08 #5
"Mr. Arnold" <MR. Ar****@Arnold.c omwrote in message
news:uJ******** ******@TK2MSFTN GP06.phx.gbl...
>
"Adam Clauss" <ca*****@tamu.e duwrote in message
news:13******** *****@corp.supe rnews.com...
>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.
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.

--
Adam Clauss
Jan 9 '08 #6

"Adam Clauss" <ca*****@gmail. comwrote in message
news:47******** *************** @roadrunner.com ...
"Mr. Arnold" <MR. Ar****@Arnold.c omwrote in message
news:uJ******** ******@TK2MSFTN GP06.phx.gbl...
>>
"Adam Clauss" <ca*****@tamu.e duwrote in message
news:13******* ******@corp.sup ernews.com...
>>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.

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/UploadFile/ankithakur/Passing_paramet ers_to_Windows_ Services1006200 6000204AM/Passing_paramet ers_to_Windows_ Services.aspx>

Jan 9 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6002
by: Vlad | last post by:
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...
1
2587
by: Sean | last post by:
Hi. I'm converting a project which uses windows form UI to Windows service. I just finished converting but I can't use any UI (winform or console). can't Windows Service use UI? then what will be an alternative? help me. :-)
5
8472
by: Brian Patrick | last post by:
I have an application model which will consist of a front-end configuration application, which needs to control the state of a back-end vb.net windows service (which is the component that does all the work). Think of this in the same manner as say microsoft management console and the w3svc (inetinfo) service. What should the standard communication protocol be between the configuration app and the service in this model? For example,...
3
4474
by: Rob | last post by:
Can a form be opened from a Windows service? I have a windows service that I would like to open a form from a notify icon. I cannot get the Notify Icon to display nor can I open a form. Any help would be greatly appreciated. Rob
2
2766
by: Glenn | last post by:
Hello Is it possible to pass arguements to a .net service once it is in a running state. If this is not possible , are they alternative ways in which to achive the same thing? Glenn
17
6442
by: UJ | last post by:
Is there any way for a windows service to start a windows program ? I have a service that will need to restart a windows app if it needs to. TIA - Jeff.
2
4678
by: letibal | last post by:
Hello, I have written a windows service and created an installer for it. The service runs under the system accounts. When started, it launches a GUI. By default, the InteractiveProcess property of the service is not set (this can be checked by right-clicking on the service in the Services window (Admin tools>Services), choosing Properties, LogOn tab). In order to enable my service to launch a GUI at startup, I added the following lines...
4
8832
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... Following the samples online, we implemented a windows service in .Net. Like most services, there's a worker thread actually doing stuff in the background. The problem we've run into is how to get the service to exit when the worker thread has a fatal error *and* get the SCM to invoke the auto-restart configuration? The worker thread can error out while the parent thread in the server process chugs along. We can set the exit...
5
3306
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name? Why do I need to set a property within my code to the service name? Are all these required or am I just doing this for consistency purposes?
0
8969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9476
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9208
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6053
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.