Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Two WIN Services using 1 executable

Status
Not open for further replies.

rgilchrist

Programmer
Jul 7, 2003
2
GB
Hi
I am trying to run 2 WIN Services from one executable, although both services install and run perfectly when installed on their own. When I use the code

static void Main(string[] args)
{
ServiceBase sb1 = new Service1();
ServiceBase sb2 = new Service2();

sb1.ServiceName = "Service1";
sb2.ServiceName = "Service2";

System.ServiceProcess.ServiceBase[] ServicesToRun;
ServicesToRun = new System.ServiceProcess.ServiceBase[] {sb1,sb2};
System.ServiceProcess.ServiceBase.Run(ServicesToRun);
}

Both services install, but when I start them, the second service listed in the ServicesToRun (in this case sb2) always executes the first service's OnStart method.

Can anyone help?

Cheers Rob
 
Service1 and Service2 are separate classes that inherit from ServiceBase? And they both have their own OnStart Event handlers?

Chip H.
 
Hi Chiph
Thanks for the reply, but I have Service 1 + 2 as seperate classes that inherit from ServiceBase and have defined OnStart methods for each of them. But it still always starts Service 1.

I am developing this in VS Studio, do you think it is doing somehting in the background?

Cheers
Rob

 
And your installer knows about the two different classes?

You might want to check your registry under:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
to see if they got installed correctly.

Chip H.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top