这个问题似乎得到了广泛的讨论,但在我的具体情况下,我在找到解决办法方面有问题。
我的服务被设置为在Local System
帐户下运行。在我的第一台安装了Windows7 SP1 (64位)的机器上,一切正常工作。但是,就在我尝试用Windows 2008 R2 SP1 (64位)在我的第二台计算机上启动服务之后,甚至连一次都没有,而且我面临着这个恼人的错误:
Windows could not start the ProService service on Local Computer
Error 1053: The service did not respond to the start or control request in a timely fashion
System Log
显示了两个条目:
The ProService service failed to start due to the following error:
The service did not respond to the start or control request in a timely fashion.
以及:
A timeout was reached (30000 milliseconds) while waiting for the ProService service to connect.
执行情况如下:
Program.cs:
static void Main()
{
AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;
ServiceBase.Run(new ServiceBase[] { new ProService() });
}
static void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
if (e != null && e.ExceptionObject != null)
{
Logger.Record(e.ExceptionObject);
}
}
ProService.cs:
public ProService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
try
{
RequestAdditionalTime(10000);
FireStarter.Instance.Execute();
}
catch (Exception e)
{
Logger.Record(e);
throw;
}
}
OnStart
方法刚刚启动一个新线程,因此它几乎不需要时间加载即可执行。为了以防万一,我使用了RequestAdditionalTime
语句--拒绝将这件事作为我问题的根源。此外,正如您可以看到的,我正在处理所有的异常,但在启动期间没有异常写入我的自定义服务事件日志(顺便说一句:日志记录在第一台win7机器上运行)。怎么调查到底发生了什么?
发布于 2013-01-04 09:08:44
我已经弄清楚了几个步骤发生了什么:
OnStart
方法。所以基本上我有过时的配置文件。以前,服务是在.NET 4.5下编译的,然后我将框架更改为4.0,并将文件部署到服务器,但保留了以前的配置文件(我更改了目标框架,因为我的开发机器有.NET 4.5,而服务器没有)。我不会想到,如果没有任何合理的信息,显示的线条会隐藏所有的问题,这可能有助于跟踪混乱。
发布于 2013-01-02 14:53:44
检查缺少的依赖项/DLL。
如果您还没有这样做,允许将您的服务作为常规应用程序调用(这是一种用于长期调试的很好的技术),并查看它是否在您的Windows 2008机器上正确启动。
如果以这种方式工作,那么在LocalSystem帐户中运行可能会出现问题。接下来从运行在LocalSystem帐户(这里的示例设置)中的命令提示符启动应用程序。
发布于 2013-10-31 15:08:41
我尝试了以下修复,它是在这个链接中提供的
但我还是有问题要开始服务。
对我起作用的方法是,
https://stackoverflow.com/questions/14121079
复制相似问题