这个问题似乎被广泛讨论,但我在找到解决方案方面遇到了困难。
我的服务设置为在“本地系统”帐户下运行。在我安装了Windows 7 SP1(64位)的第一台机器上,一切都按预期工作。但是,在我尝试在安装有Windows Server 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
系统日志显示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()
发生了什么?你能贴一些该方法的代码吗? - Marcel N.FireStarter.Instance.Execute()
包含var thread = new Thread(x => WatchThread(new ThreadStart(ExecuteInternal))); thread.Start();
框架已安装, 两台机器上一样。不幸的是,在fuslogsw
窗口中没有任何输出(我完成了来自此来源的所有步骤:http://www.neovolve.com/post/2010/05/28/Resolving-assembly-bind-failures-on-a-server.aspx,然后尝试启动我的服务)。 - jwaliszko