Boris
Boris

Reputation:

.NET Windows Service - multiple services in one project

Currently, I have a project with a Windows Service. I also created another "Setup Project" which installs the Windows Service.

My question is this: Can I add another Windows Service to the same project? (This way, I can use 1 installer, and share some code between the services more easily.) If I can, does that mean when one service encounters errors then both services are stopped, or do they error out independently of each other?

Are there any other differences between coding 1 service per project, or having multiple services in one project?

Upvotes: 23

Views: 26480

Answers (2)

Scott
Scott

Reputation: 2183

I know this is already answered, but if you'd like an example (code) of how to run two services in the same project please have a look at my answer to a similar question:

Can I have multiple services hosted in a single windows executable.

Thanks!

Upvotes: 7

kemiller2002
kemiller2002

Reputation: 115488

yes, you can have multiple services in the same project. Although they both use the same exe, they are loaded into different memory spaces and act independently of each other.

Upvotes: 9

Related Questions