473,387 Members | 1,455 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Multiple instances of a Windows Service

MW
Hi all,

I have written a windows service application and setup project to
install/deinstall my service.

There is a requirement to run one more instance of the same service with
different set of configurations and connecting to a different database. Both
the services will run on the same box. Is it possible to do that?

Someone suggested that there are entries in the windows registry that can be
duplicated to achieve it. I want to first investigate if there is a better
option within .NET. If not, then atleast know what entries should be
duplicated and what values should be changed before I go ahead.

Any thoughts will be most welcome

TIA
Wazir

Jul 21 '05 #1
3 2574
There are a number of extra fun things you can do with your service
registry settings. Code to add these should be in your installer when
installing. You have to look for them and remove them when
uninstalling if you want your MSI to be people friendly.

- Lee

"MW" <mw*********@hotmail.com> wrote in message
news:O0***************@tk2msftngp13.phx.gbl...
Hi all,

I have written a windows service application and setup project to
install/deinstall my service.

There is a requirement to run one more instance of the same service with different set of configurations and connecting to a different database. Both the services will run on the same box. Is it possible to do that?

Someone suggested that there are entries in the windows registry that can be duplicated to achieve it. I want to first investigate if there is a better option within .NET. If not, then atleast know what entries should be
duplicated and what values should be changed before I go ahead.

Any thoughts will be most welcome

TIA
Wazir

Jul 21 '05 #2
There are a number of extra fun things you can do with your service
registry settings. Code to add these should be in your installer when
installing. You have to look for them and remove them when
uninstalling if you want your MSI to be people friendly.

- Lee

"MW" <mw*********@hotmail.com> wrote in message
news:O0***************@tk2msftngp13.phx.gbl...
Hi all,

I have written a windows service application and setup project to
install/deinstall my service.

There is a requirement to run one more instance of the same service with different set of configurations and connecting to a different database. Both the services will run on the same box. Is it possible to do that?

Someone suggested that there are entries in the windows registry that can be duplicated to achieve it. I want to first investigate if there is a better option within .NET. If not, then atleast know what entries should be
duplicated and what values should be changed before I go ahead.

Any thoughts will be most welcome

TIA
Wazir

Jul 21 '05 #3
MW
Thanks for your post Lee.

I did get around to solving my problem without having to mess around with my
service registry settings. For those interested, this is how I did it.

Since I wanted to create two instances of my service I wanted to identify
them by their service names. Hence I created another constructer with the
service name as a parameter. Based on the sevice names I could look up
different configuration files for each.

Public Sub New(ByVal sServiceName As String)
MyBase.New()
' This call is required by the Component Designer.
InitializeComponent()

' Add any initialization after the InitializeComponent() call
Me.CanShutdown = True
Me.ServiceName = sServiceName
End Sub

I then edited the Main sub of the service class

' The main entry point for the process
<MTAThread()> _
Shared Sub Main()
Dim ServicesToRun() As System.ServiceProcess.ServiceBase

' More than one NT Service may run within the same process. To add
' another service to this process, change the following line to
' create a second service object.

ServicesToRun = New System.ServiceProcess.ServiceBase() {New
myService("Service1"), New myService("Service2")}
System.ServiceProcess.ServiceBase.Run(ServicesToRu n)
End Sub

Step three.- Added another ServiceInstaller to my projectInstaller for the
second instance and the set the displayname and servicename properties
appropriately

Create new builds for the service project and the setup project and
installed the msi. Service Control Manager showed both services and both
started successfully.

"Lee Gillie" <AN*******************@odp.com> wrote in message
news:OQ**************@TK2MSFTNGP12.phx.gbl...
There are a number of extra fun things you can do with your service
registry settings. Code to add these should be in your installer when
installing. You have to look for them and remove them when
uninstalling if you want your MSI to be people friendly.

- Lee

"MW" <mw*********@hotmail.com> wrote in message
news:O0***************@tk2msftngp13.phx.gbl...
Hi all,

I have written a windows service application and setup project to
install/deinstall my service.

There is a requirement to run one more instance of the same service

with
different set of configurations and connecting to a different

database. Both
the services will run on the same box. Is it possible to do that?

Someone suggested that there are entries in the windows registry

that can be
duplicated to achieve it. I want to first investigate if there is a

better
option within .NET. If not, then atleast know what entries should be
duplicated and what values should be changed before I go ahead.

Any thoughts will be most welcome

TIA
Wazir


Jul 21 '05 #4

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

Similar topics

2
by: Nigel | last post by:
Has anyone got any links to sites, articles etc or can help with how to write a Windows service that supports multiple instances in the way that MS SQL does? (I have an existing service and just...
1
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...
0
by: Ricardo | last post by:
Hi. I've built a windows service and I need to make an installation program that creates multiple instances of this service. Being more specific, what I need is to run the installation, ask the...
3
by: Steve Amey | last post by:
Hi all Is it possible to retrieve data from a Windows Service? Let's say I have a service that contains code in the OnStart method that creates a DataSet, from a client application I'm using a...
10
by: John | last post by:
I currently have a Windows Service that runs Transactions that are very Processor/Memory Intensive. I have a requirement to deploy multiple instances of the Web service on the Same server. Each...
1
by: sunil | last post by:
Hello All. I have written a program as an exe that performs some kind of order processing. The program is first configured and then started manually. I have have multiple instances of this...
0
by: Sunil Pandita | last post by:
Hi all, I have created a windows service that is working well. Now i want to create the multiple instances of this service on the same box. How could it be possible?. One way that I thought...
1
by: mikelujan | last post by:
Hi, Our application starts an external application using System.Diagnostics.Process class and the Start() method, as per code snippet below. This application run as a Windows service, and must...
0
by: jigsmshah | last post by:
I have a windows service developed in C#.I am reading the connection string from an ini file and also i am reading 3 image file from the bin directory. now the new requirement is that there will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.