错误 1053 服务没有及时响应启动或控制请求 [英] Error 1053 the service did not respond to the start or control request in a timely fashion
本文介绍了错误 1053 服务没有及时响应启动或控制请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经创建并安装了几次服务.最初它工作正常,但在对服务代码进行一些更改后,当我在 Services.msc 中重新启动服务时,它开始出现错误:
I have created and installed a service a couple of times. Initially it was working fine, but after some changes in the service Code it start giving the error when I restart the service in Services.msc :
错误 1053:服务没有及时响应启动或控制请求
Error 1053: the service did not respond to the start or control request in a timely fashion
代码:
public partial class AutoSMS : ServiceBase
{
public AutoSMS()
{
InitializeComponent();
eventLog1.Clear();
if (!System.Diagnostics.EventLog.SourceExists("MySource"))
{
System.Diagnostics.EventLog.CreateEventSource(
"MySource", "MyNewLog");
}
eventLog1.Source = "MySource";
eventLog1.Log = "MyNewLog";
Timer checkForTime = new Timer(5000);
checkForTime.Elapsed += new ElapsedEventHandler(checkForTime_Elapsed);
checkForTime.Enabled = true;
}
protected override void OnStart(string[] args)
{
eventLog1.WriteEntry("In OnStart");
}
protected override void OnStop()
{
eventLog1.WriteEntry("In onStop.");
}
void checkForTime_Elapsed(object sender, ElapsedEventArgs e)
{
string Time = "15:05:00";
DateTime dateTime = DateTime.ParseExact(Time, "HH:mm:ss",
CultureInfo.InvariantCulture);
if (DateTime.Now == dateTime) ;
eventLog1.WriteEntry(Time);
}
}
这是我的主要方法代码
static void Main()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new AutoSMS()
};
ServiceBase.Run(ServicesToRun);
}
我也尝试了以下步骤:
- 转到开始">运行"> 并键入 regedit
- 导航到:HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControl
- 选择控制文件夹后,右键单击右侧窗格并 - 选择新的 DWORD 值
- 将新的 DWORD 命名为:ServicesPipeTimeout
- 右键单击 ServicesPipeTimeout,然后单击修改
- 点击小数,输入180000",然后点击确定
- 重启电脑
我曾经使用以下命令安装和卸载它:
I used to install and uninstall it with following command :
installutil AutoSMS.exe
installutil /u AutoSMS.exe
推荐答案
就我而言,我在调试模式下发布服务.
解决方案是:
- 将解决方案更改为发布模式
- 使用命令
InstallUtil -u WindowsServiceName.exe
卸载旧服务 - 重新安装服务
InstallUtil -i WindowsServiceName.exe
之后效果很好.
这篇关于错误 1053 服务没有及时响应启动或控制请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文