c# - Multiple Windows Services in One exe -
I'm trying to create many Windows services to do many different things. For example, I need Windows services:
- Send a daily report via email
- From time to time, some archived information every 30 minutes
- Clear etc.
I have different functions to meet the needs of windows so I really do not like the idea of placing it in one service.
What I have so far is a project in Visual Studio 2008. I have created a Windows service, I have set a timer on the online event (it just writes in Test file every 5 seconds for testing purposes). I then added an installer to the project and when I run InstallUtil.exe, everything works fine.
The problem occurs when I add a second window service for the same project. With the service of the other windows, I have installed an onstart code again with the same logging information (slightly different so I can tell which service is typing in the log), I have the main event from Program.cs Changed from:
Fixed zero main (string [] args) {ServiceBase [] ServicesToRun = new servicebase [] {new service1 ()}; ServiceBase.Run (ServicesToRun); } { From:
Fixed zero main (string [] args) {ServiceBase [] servicesToron = new servicebase [] {new service 1 (), New service 2 ()}; ServiceBase.Run (ServicesToRun); } At this point, there are no compile time errors, but Service 2 does not do anything ... the logging task never fire.
The fact that I compressed it down is the fact that the "installer" does not have it attached to the other service, then I tried to add an installer with the first service (i.e., right click on service designer And click "Add Installer"). Now, when I go to the ProjectInstaller.cs file, there is another service installer (Service Installer 2).
Now when I create a project and try to install services, and I try to start the Service "Control Panel" window, and I start Service1, I get the following error message :
The Service 1 service on Windows local computer could not start.
Error 1083: Executable program that is configured to run this service does not implement the service.
I get the same error message while trying to start Service 2 (with the exception that the error message is identified
< Item class = "post-text"
Itemprop = "text">
I have come to know how an executable but two services to each service service manager Your name is installed with the ability to install / stop. I think this is what you want, right? Here I am
You can find demo codes here:
Comments
Post a Comment