C# 重复的windows服务,不同的名称和位置-将不会启动

C# 重复的windows服务,不同的名称和位置-将不会启动,c#,windows-services,C#,Windows Services,我有一个windows服务,其名称由app.config设置。 我将名称设置如下: ServiceBase.SerivceName是在服务类构造函数上设置的(我已删除了Service.Designer中ServiceName的设置): ServiceInstaller按如下方式设置DisplayName和ServiceName: ServiceInstaller.DisplayName = config.AppSettings.Settings["ServiceName"].Value; Ser

我有一个windows服务,其名称由app.config设置。 我将名称设置如下:

ServiceBase.SerivceName是在服务类构造函数上设置的(我已删除了Service.Designer中ServiceName的设置):

ServiceInstaller按如下方式设置DisplayName和ServiceName:

ServiceInstaller.DisplayName = config.AppSettings.Settings["ServiceName"].Value;
ServiceInstaller.ServiceName = ServiceInstaller.DisplayName;
所有这些都按预期工作,因此该服务可以与重复服务一起正常安装。
它们有不同的名称和位置。
在“服务”列表中显示为单独的条目

但我一次只能启动一项服务。我在尝试启动第二个服务时遇到的错误是无效的:

The service is not responding to the control function.
尝试运行时记录了两个系统事件:

A timeout was reached (30000 milliseconds) while waiting for the Blah Service service to connect.  

The Blah Service service failed to start due to the following error:
The service did not respond to the start or control request in a timely fashion.
感谢您的帮助


谢谢。

如果没有足够的信息来提供当前问题的答案,我建议使用-它可以轻松地在.NET中安装、配置和调试windows服务。

事件日志中有什么有用的信息吗?您是否无意中尝试共享不可共享的资源?我已编辑了该问题并添加了两个记录的系统事件。由于这些服务是从两个不同的文件夹位置安装的,我认为它们没有共享任何资源。谢谢。我会在你的OnStart上放一些日志,看看它是否被点击。是的,说得对。我试过了,但没有被击中。静态构造器也不是…构造器中有什么古怪的东西吗?您不应该在那里对服务进行任何初始化。请注意,根据文档,TopShelf不支持多个Windows服务实例。然而,不要让这阻止你。请参阅此处的更多信息:
A timeout was reached (30000 milliseconds) while waiting for the Blah Service service to connect.  

The Blah Service service failed to start due to the following error:
The service did not respond to the start or control request in a timely fashion.