c# windows 服务导致整个机器无限期挂起/崩溃
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是您代码中的错误! 也许发布一个精简版本。
按照@GWLlosa 的建议,添加大量日志记录。
It's a bug in your code! Perhaps post a cut down version.
As suggested by @GWLlosa, add copious logging.
将日志记录代码添加到服务的 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.