如何使Windows服务正常失败?

编程入门 行业动态 更新时间:2024-10-10 10:33:05
本文介绍了如何使Windows服务正常失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我希望多年来第一次构建Windows服务,并且稍微失去了一点点。我想配置服务,所以它基本上总是在失败时重新启动。这是非常无害的,无数的网络服务电话意味着许多失败点。 我如何例如如果出现未处理的异常,或者没有回头的处理过的异常,请向Windows发出我的服务失败的信号?

解决方案

一个启用恢复和自动启动配置的ServiceInstaller扩展 [ ^ ]

正如评论中所讨论的那样,你当然不希望你的服务失败,但它会像常规exe一样失败:当你没有捕获异常或者系统真的以某种方式爆炸时。重新启动选项在服务属性中配置。

I am looking to build a Windows service for the first time in ages, and have lost touch a bit. I want to configure the service so it basically always restarts on failure. It's quite innocuous, and umpteen web service calls mean many points of failure. How do I e.g. in the event of an unhandled exception, or a handled one from which there is no turning back, signal to Windows that my service has failed?

解决方案

A ServiceInstaller Extension That Enables Recovery and Autostart Configuration[^]

As discussed in the comments, you certainly don't want your service to fail but it will fail just like a regular exe will: when you don't catch an exception or if the system really blows up somehow. The restart options are configured in the Services properties.

更多推荐

如何使Windows服务正常失败?

本文发布于:2023-11-27 12:40:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638116.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!