简体   繁体   English

使用 TopShelf 创建 Windows 服务时出现“错误 1053 服务没有响应”错误

[英]"Error 1053 The Service did not respond" error when using TopShelf to create a Windows Service

I have a Windows Service created using the TopShelf library.我有一个使用TopShelf库创建的 Windows 服务。 When attempting to start the service, it gives me an error:尝试启动服务时,它给了我一个错误:

Windows could not start the HPS.MyService.Service service on Local Computer Windows 无法在本地计算机上启动 HPS.MyService.Service 服务

Error 1053: The service did not respond to the start of control request in a timely fashion.错误 1053:服务没有及时响应启动控制请求。

This error happens immediately on startup, there is no 30 second delay.此错误在启动时立即发生,没有 30 秒延迟。

The TopShelf code for my service looks like this:我的服务的 TopShelf 代码如下所示:

public static void Main()
{
    HostFactory.Run(x =>
    {
        x.Service<TopshelfHangfireService>();
        x.EnableServiceRecovery(r => r.RestartService(TimeSpan.FromSeconds(30)));
        x.SetServiceName("HPS.MyService");
        x.StartAutomaticallyDelayed();
    });
}

I've validated that I can run this service directly from a console window by invoking the executable using the same account that the service is supposed to run as.我已经验证我可以直接从控制台窗口运行此服务,方法是使用服务应该运行的相同帐户调用可执行文件。

Why am I getting this error - how can I get my service to successfully start?为什么我会收到此错误 - 如何让我的服务成功启动?

This service was installed with a service name of "HPS.MyService.Service" as the error message indicates, but the C# code tries to explicitly set it to "HPS.MyService".如错误消息所示,此服务是使用“HPS.MyService.Service”服务名称安装的,但 C# 代码尝试将其显式设置为“HPS.MyService”。 This mismatch between names is the source of the error.名称之间的这种不匹配是错误的根源。 You can change the service to be called "HPS.MyService" when installing it, or change the service name line to您可以在安装时将服务更改为“HPS.MyService”,或者将服务名称行更改为

x.SetServiceName("HPS.MyService.Service");

Or: entirely remove the call to x.SetServiceName, since that limits you to using a particular name for the service, and you're able to control the service name when installing it anyways.或者:完全删除对 x.SetServiceName 的调用,因为这限制了您对服务使用特定名称,并且无论如何您都可以在安装时控制服务名称。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Topshelf 服务不会作为服务启动:错误 1053 服务没有响应..” - Topshelf service wont start as a service: Error 1053 The service did not respond.." 错误1053:服务没有及时响应 - Error 1053: Service did not respond in time VS C# tcp 服务器/侦听器收到错误 1053 服务在作为 Windows 服务运行时没有及时响应 - VS C# tcp server/listener gets error 1053 the service did not respond in a timly fashion when ran as a Windows Service Windows服务无法启动&#39;错误1053:服务未及时响应启动或控制请求&#39; - Windows Service won't start 'Error 1053: The service did not respond to the start or control request in timely fashion' 1053 windows服务没有及时响应 - 1053 windows service did not respond in timely fashion 错误 1053:安装并运行 WCF 服务时,服务未及时响应启动或控制请求 - Error 1053: The service did not respond to the start or control request in a timely fashion, when intalled and ran a WCF service 错误 1053 服务没有及时响应启动或控制请求 - Error 1053 the service did not respond to the start or control request in a timely fashion 错误 1053 服务没有响应启动或控制请求 - Error 1053 the service did not respond to the start or control request 错误1053,服务没有及时响应请求 - Error 1053. The service did not respond to the request in a timely manner 错误1053:服务未及时响应启动或控制请求 - Error 1053: the service did not respond to the start or control request in a timely fashion
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM