c# windows 服务导致整个机器无限期挂起/崩溃

发布于 2024-07-13 01:23:33 字数 379 浏览 7 评论 0原文

我有一个 C# 2.0 Windows 服务(100% 托管代码),并且偶尔在启动/重新启动时会导致整个计算机 (Windows Server 2003) 无限期挂起。 当我单击“启动服务”时,服务控制进度条到达一半,然后计算机在本地终端和远程桌面会话中完全没有响应。 唯一的解决办法就是重新启动机器。

系统事件日志中没有任何内容。

该服务是一个远程服务器,在启动时通过 TCP 对其他远程服务器(也是 Windows 服务)进行远程调用。

起初我认为这可能是网卡问题,所以我们更换了机器(更好的规格,不同的网卡),但在大约十分之一的重新启动中我仍然遇到同样的问题......。 所以90%的时间都是完全没问题的。

我究竟做错了什么?

I have a C# 2.0 windows service (100% managed code) and occasionally when it is started/restarted it causes the entire machine (Windows Server 2003) to hang indefinitely. When I click “Start the service” the service control progress bar gets halfway then the machine becomes completely unresponsive at the local terminal and remote desktop sessions. The only solution is to restart the machine.

There is nothing in the system event log.

The service is a Remoting server that on start up makes Remoting calls to other Remoting servers (also windows services) over TCP.

At first I was thinking this maybe a network card issue so we replaced the machine (better spec, different network card) but I still get the same issue in about 1 in 10 restarts …. so 90% of time it is completely fine.

What am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

何以心动 2024-07-20 01:23:34

这是您代码中的错误! 也许发布一个精简版本。

按照@GWLlosa 的建议,添加大量日志记录。

It's a bug in your code! Perhaps post a cut down version.

As suggested by @GWLlosa, add copious logging.

辞慾 2024-07-20 01:23:34

将日志记录代码添加到服务的 onStart 例程中。 您应该能够找出哪些函数调用正在占用您的 CPU,并从那里开始工作。

Add logging code to the service's onStart routine. You should be able to figure out which function calls are spiking your CPU, and work from there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文