服务错误1053:无法及时启动
本文关键字:启动 错误 1053 服务 | 更新日期: 2023-09-27 18:17:08
在你问之前,是的,我在这个问题上搜索了又搜索,尝试了其他人的方法,但一无所获。我试过了:
- 以释放模式运行
- 在LocalSystem, LocalService和命名帐户上运行
- 我的项目中没有调试代码
我的项目总结是一个Windows服务,它扫描源文件夹中的文件,并在设定的时间,转换它们并将它们放在目标文件夹中。这些设置可以在GUI中更改,GUI会更改服务定期扫描的XML文件。
成品包在InstallShield中。一切工作从VisualStudio。我可以安装程序,服务工作得很好。当我使用我的发布版本并在同一台机器上安装它时,我得到这个1053错误。
这是我的OnStart protected override void OnStart(string[] args)
{
// Update the service state to Start Pending.
ServiceStatus serviceStatus = new ServiceStatus();
serviceStatus.dwCurrentState = ServiceState.SERVICE_START_PENDING;
serviceStatus.dwWaitHint = 100000;
SetServiceStatus( this.ServiceHandle, ref serviceStatus );
// Set up a timer to trigger every 30s
System.Threading.Thread t1 = new System.Threading.Thread( new System.Threading.ThreadStart( this.InitTimer ) );
t1.Start();
// Set folders and time from xml
System.Threading.Thread t2 = new System.Threading.Thread( new System.Threading.ThreadStart( this.InitSettings ) );
t2.Start();
// Update the service state to Running.
eventLog1.WriteEntry( "Service successfully started", EventLogEntryType.Information, eventId++ );
serviceStatus.dwCurrentState = ServiceState.SERVICE_RUNNING;
SetServiceStatus( this.ServiceHandle, ref serviceStatus );
}
这是我的主
public WTVService(string[] args)
{
InitializeComponent();
string eventSourceName = "Searcher";
string logName = "WTVConverter";
if ( args.Count() > 0 )
{
eventSourceName = args[0];
}
if ( args.Count() > 1 )
{
logName = args[1];
}
eventLog1 = new EventLog();
if ( !EventLog.SourceExists( eventSourceName ) )
{
EventLog.CreateEventSource( eventSourceName, logName );
}
eventLog1.Source = eventSourceName; eventLog1.Log = logName;
}
请告诉我其他可能有用的信息。
编辑:另外,如果它有区别,错误会立即出现,而不是在假定的30秒超时规则之后。
这很有趣。我相信在这里使用InstallShield的人是有限的,但这可能会对某些人有所帮助。最终工作的是将构建模式从SingleImage更改为DVD-5。我说不出原因,但它现在运行得很好。我在一台从未运行过我的程序的机器上进行了测试,结果一切正常。
当您通过InstallShield部署任何服务时,您需要选择LocalSystem用户名或Admin用户凭据。
要执行任何windows服务,它需要Admin用户或LocalSystem用户。
因此在InstallShield中为服务提供了用户凭据。