【发布时间】:2012-12-16 18:18:31
【问题描述】:
这个问题似乎得到了广泛的讨论,但在我的特殊情况下,我很难找到解决方案。
我的服务设置为在Local System 帐户下运行。在我的第一台安装了 Windows 7 SP1(64 位) 的机器上,一切正常。但是,就在我尝试使用 Windows Server 2008 R2 SP1(64 位) 在我的第二台机器上启动该服务之后,甚至没有通过,我正面临这个恼人的错误: p>
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 显示 2 个条目:
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 机器上工作)。如何调查发生了什么?
【问题讨论】:
-
FireStarter.Instance.Execute()会发生什么?你能发布一些该方法的代码吗? -
再一次,如果发生错误需要不到一秒钟的时间,那么可能会发生程序集绑定异常。您可以通过启用 FusionLog 并使用 FusionLog 查看器来跟踪这一点:msdn.microsoft.com/en-us/library/e74a18c4(v=vs.100).aspx。此外,请确保在第二台计算机上安装了适当的 .NET 框架。
-
FireStarter.Instance.Execute()包含var thread = new Thread(x => WatchThread(new ThreadStart(ExecuteInternal))); thread.Start();框架已安装,两台机器上相同。不幸的是,我在fuslogsw窗口中的输出为空(我完成了此来源的所有步骤:neovolve.com/post/2010/05/28/…,然后尝试启动我的服务)。 -
那么我能想到的唯一有用的事情(而且我自己也用过)是在该机器上使用 Intellitrace 独立收集器并收集有关执行路径的跟踪详细信息。在此处查看有关您需要的设置的更多信息:msdn.microsoft.com/en-us/library/vstudio/hh398365.aspx。一旦启动并运行,您将能够准确地看到执行了什么,并希望查明问题。
标签: .net windows-services windows-server-2008-r2