由于 TaskManagerClosing,.net 表单不断消失
所以这个让我难住了,而且看起来很奇怪。 我编写了一些 C# 表单,它们充当客户端服务器应用程序设置中的“服务器”组件。 (客户端发送 udp 数据,服务器程序发出一些数字并发回结果。) 由于各种原因,1 个表单的 4 个实例和另一个表单的 1 个实例同时运行。我有一个 bat 文件,可以在电源重置时自动启动所有这些表单。
无论如何,所以我试图让它一直运行并让它们变得可靠。 一个月前它工作得很好,但在过去的几周里我注意到它们已经消失了。有时他们熬夜一天,有时四天,但随后就消失了。 (直到最后一次出现,它们似乎都会同时消失,但我没有观察,所以我无法确定。最后一次,由于某种原因,一种不同的形式保持运行。)
所以我添加了一些日志记录和发现所有表单确实在同一秒消失,并且 _FormClosing 事件显示 TaskManagerClosing 的 CloseReason。
我知道事实上没有其他人可以物理访问该机器。
什么可能导致这种情况发生? 还有其他人开始认为我的计算机可能被感染了吗?只是一个想法,但无论如何,这种行为对于恶意软件或病毒来说都是奇怪的。特别是因为计算机上的其他一切似乎都表现得很好。也就是说我确实安装了tightVNC,也许那不是那么安全。
除此之外没有什么其他的,也许防病毒软件或广告感知正在关闭表格?
想法? 提前致谢。
So this one has me stumped, and seems really odd.
I wrote some c# forms which act as the "server" component in a client server app setup.
(Client sends udp data, server program chugs some numbers and send back results.)
Due to various reasons, there are 4 instances of 1 form and 1 instance of another form all running at the same time. And I have a bat file that automatically starts all these forms in case of a power reset.
Anyways, so I am trying to leave this running all the time and have them be somewhat reliable.
It was working fine a month ago, but over the past few weeks i have noticed they have been disappearing. Sometimes they stay up for a day, sometimes 4, but then just disappear.
(Up until the last occurance they would all disappear seemingly at the same time, but i wasn't watching so i couldn't be sure. This last time the one different form stayed running for some reason.)
So I added some logging and found that all the forms do disappear at the same second, and the _FormClosing event shows a CloseReason of TaskManagerClosing.
I know for a fact no other person has physical access to the machine.
What could cause this to happen?
Anybody else starting to think maybe my computer is infected?? Just a thought, but this behaviour would be odd for malware or a virus anyways. Especially since everything else on the computer seems to behave just fine. That said I do have tightVNC installed, maybe that isn't that secure.
Other than that there isn't much else, maybe antivirus software or Ad-Aware is closing the forms??
Thoughts?
Thanks in Advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是一些想法,因为这看起来确实很奇怪。
首先,MSDN 文档具有误导性指出 CloseReason.TaskManagerClosing 指示“Windows 任务管理器正在关闭应用程序”。相反,当窗口收到 WM_CLOSE 消息 (0x10) 时,CloseReason.TaskManagerClosing 似乎被设置为关闭原因,该消息可能源自系统上的任何进程,而不一定是任务管理器。
这就提出了一个问题:为什么在这些进程上调用 WM_CLOSE?一种可能性是侦听 UDP 数据包会触发安全软件(病毒/广告软件)上基于规则的过滤器,这可能会在进程关闭时出现在软件和 Windows 事件日志中。除此之外,如果不了解拥有过程,就很难诊断。
虽然它没有解决根本原因,但一种实用的选择是取消 WM_CLOSE 请求以响应 FormClosing 事件。
另一种选择是将软件重组为 Windows 服务而不是应用程序。服务往往更适合服务器类型的应用程序,因为它们在自己的用户会话中运行。但它也需要将用户界面功能与服务器功能分开,并且也无法解决根本问题。
最后,如果这是服务器,您可能需要重新访问任何已安装的可能无关的服务或实用程序,并以某种方式将 WM_CLOSE 命令发送到应用程序实例。此外,将服务器应用程序实例移至干净的服务器可能是隔离问题的实用方法。
Just some thoughts, since this does seem very odd.
First, the MSDN documentation is misleading when it states that CloseReason.TaskManagerClosing indicates that "Windows Task Manager is closing the application". It appears, rather, that the CloseReason.TaskManagerClosing is set as the close reason when the window receives a WM_CLOSE message (0x10), which could originate from any process on the system, and not necessarily Task Manager.
This raises the question: why is WM_CLOSE being called on these processes? One possibility is that listening for UDP packets is triggering a rule-based filter on the security software (virus/adware), which may show up in the software and Windows event logs around the time the processes are closed. Beyond that, it's difficult to diagnose without knowing the owning process.
While it doesn't address the root cause, one practical option is simply to cancel the WM_CLOSE request in response to the FormClosing event.
Another option is to restructure the software as a Windows service rather than a application. Services tend to be better-suited for server-type applications, since they run in their own user session. But it would also require separating the user interface functionality from the server functionality, and also wouldn't address the underlying problem.
Finally, if this is a server, you might want to revisit any installed services or utilities that may be extraneous and somehow sending the WM_CLOSE command to the application instances. In addition, moving the server application instances to a clean server might be a practical approach to isolating the issue.