我可以在单个 Windows 可执行文件中托管多个服务吗
我的问题与以下问题基本相同,但答案对我没有帮助。
本质上,我有 3 个服务,比如说“Service1”、“Service”和“Service3”。
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new Service1("Service1"),
new Service2("Service2"),
new Service3("Service3")
};
ServiceBase.Run(ServicesToRun);
我也有相应的安装程序类 其中每个服务的 serviceInstaller.ServiceName = "ServiceX"。
当我使用 installutil 时,我确实在服务管理器上看到了所有 3 个服务。但是,当我启动它们(其中任何一个或全部)时,只有第一个(“Service1”)正在运行。
我知道这是微不足道的,我可能可以为每个项目都有不同的安装程序项目,但就我而言,仅使用一个在语义上更有意义,
感谢您的帮助,
谢谢 维努
My question is essentially the same as the following one but the answer did not help me.
.NET Windows Service - multiple services in one project
Essentially, I have 3 services, lets say "Service1", "Service" and "Service3".
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new Service1("Service1"),
new Service2("Service2"),
new Service3("Service3")
};
ServiceBase.Run(ServicesToRun);
I also have installer classes with corresponding
serviceInstaller.ServiceName = "ServiceX" for each of these services.
When I use installutil, i do see all 3 services on the Service manager. However, when i start them (any or all of them) only the first one ("Service1") is running.
I know this is trivial and i can probably have different installer projects for each of these but in my case, it semantically makes more sense to use just one
Your help is appreciated
Thanks
Venu
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我创建了一个 3 服务项目(如下),它为每个服务使用一个项目安装程序。然后我添加了一个安装程序项目,它将服务安装到服务管理器中。我的工作流程如下:
这在服务管理器中提供了三个不同的服务:Service1、Service2 和 Service3
享受吧!
http://code.google.com/p/multi-service-install/
编辑:
我已更新存储库中的代码以拥有一个可执行文件但有两个服务。每个服务都以自己的名称和启动/停止的能力安装到服务管理器中。我想这就是你想要的,对吧?这就是我所做的:
该代码仍然可以从上述相同的链接下载。
谢谢!
I created a 3 service project (below) which uses a project installer for each service. I then added an installer project which installs the services into service manager. Here was my workflow:
This gives me three distinct services in service manager: Service1, Service2 and Service3
Enjoy!
http://code.google.com/p/multi-service-install/
EDIT:
I have updated the code in the repository to have one executable but two services. Each service installs to the service manager with its own name and ability to start/stop. I think this is what you're wanting, correct? Here is what I did:
The code can still be downloaded from the same link as above.
Thanks!