即使配置了恢复选项,Windows 服务也无法重新启动
在我的 Window Service 中,如果启用服务连接到 SQL Server,它将引发异常并且 Windows 服务将不会启动。为了克服这种情况,我将 Windows 服务的恢复选项设置为“第一次失败”、“第二次失败”以重新启动服务、“1 天后重置失败计数”以及“重新启动服务”为 0 分钟。
我想要的是,当服务抛出异常(未处理)时,服务应该选择我已配置的恢复选项,并且应该尝试重新启动服务。但这是行不通的。
配置恢复选项服务后,如果我进入任务管理器并手动结束进程,则仅应用此恢复选项。
有人能帮我解决这个问题吗?
In my Window Service if Service is enable to connect to SQL Server it throws an exception and windows service will not start. To overcome this situation I have set recovery option of Windows Service to First Failure, Second Failure to Restart the Service, Reset fail count after 1 day and Restart Service to 0 minutes.
What I want is when service throws an exception(unhandled) service should go for recovery option which I have configured and should try to restart the service. But this doesnt work.
After configuring service for recovery option if I got to the Task Manager and manually end the process then only this recovery option gets applied.
Can anyone help me on this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我们调用
Environment.Exit( -1 )
,它会向 SCM 发送信号,表明服务已崩溃,并且恢复选项将得到尊重。希望这能帮助像我这样的人。
If we call
Environment.Exit( -1 )
it send signal to SCM that service is crashed and Recovery option will get respect.Hope this will help others like me.