简体   繁体   English

安装Windows服务时出错 - 服务未及时响应启动或控制请求

[英]Error installing Windows service — The service did not respond to the start or control request in a timely fashion

I have a Windows service application which I have installed on my machine without issue. 我有一个Windows服务应用程序,我已经安装在我的机器上没有问题。 I went to install it on another machine, and I'm receiving the error 我去另一台机器安装它,我收到错误

Error 1001. An exception occurred during the Commit phase of the installation. 错误1001.安装的提交阶段发生异常。 This exception will be ignored and installation will continue. 此异常将被忽略,安装将继续。 However, the application might not function correctly after installation is complete. 但是,安装完成后,应用程序可能无法正常运行。 Cannot start service MyService on computer '.'. 无法在计算机上启动服务MyService'。'。 The service did not respond to the start or control request in a timely fashion. 该服务未及时响应启动或控制请求。

This error is popping up immediately without any hanging. 此错误立即弹出,没有任何挂起。 Normally I would only expect to see this error after a hang. 通常情况下,我只希望在挂起后看到此错误。

I'm using the .NET 4 framework, which is installed on both machines. 我正在使用.NET 4框架,它安装在两台机器上。 I've tried disabling the antivirus program thinking that might be interfering with the service startup, but that yielded the same error. 我已经尝试禁用可能干扰服务启动的防病毒程序,但是产生了同样的错误。 The firewall was also disabled. 防火墙也被禁用了。

Is there anything else that could be causing this issue? 还有什么可能导致这个问题吗?

This behaviour usually occurs when an exception is thrown in the WinService's OnStart method and is not caught in a try-catch block. 当在WinService的OnStart方法中抛出异常并且未在try-catch块中捕获时,通常会发生此行为。 I believe you can check out the exception message and stack trace using the EventViewer, if not you can easily implement a simple logging functionality using the EventLog class . 我相信您可以使用EventViewer查看异常消息和堆栈跟踪,否则您可以使用EventLog类轻松实现简单的日志记录功能。

Sometimes the exception is thrown because the service is not running under a privileged account. 有时会抛出异常,因为该服务未在特权帐户下运行。 To fix this you have to configure your installer's ServiceProcessInstaller object like the following: 要解决此问题,您必须配置安装程序的ServiceProcessInstaller对象 ,如下所示:

myServiceInstaller.Account = ServiceAccount.User;
myServiceInstaller.Username = "Domain name\User name";
myServiceInstaller.Password = "qwerty";

Thanks for your help everyone. 谢谢大家的帮助。 I realized the issue was due to the .NET Framework installed on the two different machines. 我意识到问题是由于在两台不同的机器上安装了.NET Framework。 My machine had .NET Framework 4 Client Profile and .NET Framework 4 Extended, and the other machine only had .NET Framework 4 Client Profile. 我的机器有.NET Framework 4 Client Profile和.NET Framework 4 Extended,另一台机器只有.NET Framework 4 Client Profile。 Evidently for some of the components in the service need libraries that aren't present in the .NET Framework 4 Client Profile. 显然,服务中的某些组件需要.NET Framework 4 Client Profile中不存在的库。

Since your service runs on another computer, and assuming the code is the same for both, the issue may be something having to do with permissions. 由于您的服务在另一台计算机上运行,​​并且假设两者的代码相同,因此问题可能与权限有关。 Ensure the account your service is running under has sufficient permissions to any folders where it writes files. 确保您的服务运行的帐户对其写入文件的任何文件夹具有足够的权限。 If you write to the Event Log, ensure the service' account has the necessary permissions for that. 如果您写入事件日志,请确保该服务的帐户具有相应的权限。

暂无
暂无

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

相关问题 错误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 in a timely fashion Windows服务无法启动'错误1053:服务未及时响应启动或控制请求' - Windows Service won't start 'Error 1053: The service did not respond to the start or control request in timely fashion' 启动服务:“错误1053:服务未及时响应启动或控制请求” - Starting a service: “Error 1053: The service did not respond to the start or control request in a 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 C#错误1053,服务未及时响应启动或控制请求 - C# Error 1053 the service did not respond to the start or control request in a timely fashion 发生错误1053,服务未及时响应启动或控制请求 - Im getting Error 1053 the service did not respond to the start or control request in a timely fashion 错误 1053:服务没有使用 FileSystemWatcher 及时响应启动或控制请求 - Error 1053:The service did not respond to start or control request in timely fashion with FileSystemWatcher 使用 Topshelf 时服务没有及时响应启动或控制请求 - The service did not respond to the start or control request in a timely fashion when using Topshelf 1053 windows服务没有及时响应 - 1053 windows service did not respond in timely fashion
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM