views:

456

answers:

1

I'm trying to run several similar services via ServiceBase.Run(ServiceBase[] ) but it's only running the first one. MSDN doesn't explicitly deny this; does this excerpt mean that they all must be different types? (the bold is by me, not MSDN)

Call this overload in the main() function of the service executable to load an array of associated services.

+1  A: 

That is the intent. The idea here is that you can have a single executable create "multiple services" instead of just a single type of service.

When a service is registered with the SCM, it's expected that each service is unique. This would suggest (and I believe it's the case) that each element in your array must be a unique implementation of ServiceBase.

If you really are just trying to have multiple copies of the same service, I would rethink your design. Just have the service fire off multiple threads using the same method, and it will provide that same effect with a single service instance.

Reed Copsey
The multiple threads was the original design and I was just experimenting with this. Thanks for clearing that up for me.
Austin Salonen
It should be possible to have 2 Services implementing the same type. You just have to make sure that each service has a unique service name.This scenario is particularly useful if you want to have 2 services having the same functionality but using different configurations. Say different shared folders to read files from or different databases to connect to.I have created a windows service library called Daemoniq. It supports running multiple windows services in one process. http://code.google.com/p/daemoniq/wiki/MultipleWindowsServicesOneProcess.
jake.stateresa
While it's possible, as soon as you name them separately, they're in essence two separate services ;) That being said, your approach is fine.
Reed Copsey