3

My main function is like this:

ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
    new FirstService(),
new SecondService()
};
ServiceBase.Run(ServicesToRun);

I want to run two service, but only FirstService gets started. Why is that?

lucn
  • 368
  • 1
  • 4
  • 10
  • If you comment out FirstService (so that you're only running one service) then does SecondService start? – Sean Oct 23 '12 at 11:11
  • 1
    possible duplicate so question http://stackoverflow.com/questions/1688275/can-i-have-multiple-services-hosted-in-a-single-windows-executable – pmtamal Oct 23 '12 at 11:12
  • SecondService's OnStart method does not execute. – lucn Oct 23 '12 at 12:08
  • Answer is here, this is right.: http://stackoverflow.com/questions/1688275/can-i-have-multiple-services-hosted-in-a-single-windows-executable – lucn Oct 24 '12 at 06:07

1 Answers1

0

See this link: http://www.bryancook.net/2008/04/running-multiple-net-services-within.html

Short answer: each service must have own Installer

But I think, that services should be independent and I recomend you to rethink this solution

razon
  • 3,882
  • 2
  • 33
  • 46