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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows Service with Multiple Installers

Status
Not open for further replies.

Hexonx

Programmer
Jan 10, 2001
102
US
I built a Windows Service assembly that implements two services. For better organization, I created a folder for each service to contain appropriate project files. Additionally, I created a separate ProjectInstaller for each service in the appropriate folder. All went well until I noticed that starting either of the services also the other! After wrangling around for awhile (too long) and creating a simple example to demonstrate support for a multi-service assembly, I determined that having multiple ProjectInstallers caused this side-effect, even though no other problems occurred. I combined the installers into a single installer and each service could start/stop independently.
 
I think your main should be like here:
static void Main()
{
System.ServiceProcess.ServiceBase[] ServicesToRun;
ServicesToRun = New System.ServiceProcess.ServiceBase[] {new MyFirstUserService(), new MySecondUserService()};
System.ServiceProcess.ServiceBase.Run(ServicesToRun);
}
That means the both services are running in the same process for example MyBothServices.exe and the both services are installed in the same folder and will share the same .exe.config file.
-obislavu-
 
obislavu,

You are correct. I had tried this and it solved the side-effect problem. I ultimately split the services into two projects in order for each service to have a separate Trace log. I am using the Trace class, which occurs at the AppDomain level. Since both of my services run in the same process (AppDomain), Trace messages in either service were written to both trace logs. So instead of moving away from Trace and implementing my own log writer, I simply split the two services from each other.

This has been an interesting excercise in the consequences of design decisions, whose impact is often not realized until development has begun.

Thanks for the reply.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top