Visual Studio 2008 devenv 运行应用程序,然后留下 Ghost

发布于 2024-08-17 14:16:12 字数 1405 浏览 0 评论 0原文

我正在使用 Visual Studio 开发 C#/WPF 应用程序。此应用程序使用 com 端口,然后在退出时释放它。我经常使用调试器来运行和停止该应用程序。有时,在启动调试会话时会出现异常,提示 com 端口已在使用中。

该代码总是在退出时关闭打开的 com 端口,因此我运行 portmon 来查看谁在占用该端口。事实证明,在“正常”情况下,端口被我的应用程序(portmon 中的 Process KaleidscopeApp)抓取、使用和关闭。在端口未释放的情况下,该端口正被进程“devenv”使用,该进程是 Visual Studio 本身。

在这些情况下,为什么 devenv 是 com 端口的所有者?当我关闭应用程序时,为什么它仍然保留它?只有当我关闭 Visual Studio 时,端口才会被释放。这是一种奇怪的行为,特别是因为调试器已在 Visual Studio 中专门停止。

这是 portmon 的捕获,显示了对 com 端口的访问。您可以看到典型的会话以 IRP_MJ_CREATE 开始,以 IRP_MJ_CLOSE 结束。 KaleidscopeApp 的情况总是如此。您可以看到最后一位是由 devenv 运行的。然而每次启动总是在 VS 调试器中。


357 0.11112275 KaleidscopeApp IRP_MJ_CREATE Serial4 SUCCESS 选项: 打开
358 0.00000305 万花筒应用程序 IOCTL_SERIAL_GET_PROPERTIES Serial4 成功
...

406 0.02997366 KaleidscopeApp IRP_MJ_CLEANUP Serial4 成功
407 0.03390231 万花筒应用程序 IRP_MJ_CLOSE 串行 4 成功
408 0.11443431 KaleidscopeApp IRP_MJ_CREATE Serial4 成功选项: 打开
409 0.00000727 KaleidscopeApp IOCTL_SERIAL_GET_PROPERTIES Serial4 成功
...

457 0.02995160 KaleidscopeApp IRP_MJ_CLEANUP Serial4 成功
458 0.03389956 万花筒应用程序 IRP_MJ_CLOSE 串行 4 成功
459 0.11307261 devenv.exe IRP_MJ_CREATE Serial4 成功 选项: 打开
460 0.00000185 devenv.exe IOCTL_SERIAL_GET_PROPERTIES Serial4 成功
...

501 35.55274341 devenv.exe IOCTL_SERIAL_WAIT_ON_MASK Serial4 已取消


任何见解将不胜感激!

I'm developing a C#/WPF application using Visual Studio. This app uses a com port, then releases it upon exit. I'm using the debugger to run and stop this application often. Sometimes, I get an exception when starting up a debug session saying that the com port is already in use.

The code always closes the open com port on exit, so I ran portmon to see who was holding on to the port. It turns out that in "normal" cases, the port is grabbed, used, and closed by my application (Process KaleidoscopeApp in portmon). In the case where the port is not released, the port is being used by process "devenv", which is Visual Studio itself.

Why is devenv the owner of the com port in these cases? When I close the app, why does it continue to hold it? Only when I close Visual Studio is the port released. It is strange behavior especially since the debugger has specifically halted within Visual Studio.

Here is a capture from portmon showing access to the com port. You can see a typical session begins with IRP_MJ_CREATE and ends with IRP_MJ_CLOSE. This is always the case with KaleidoscopeApp. You can see the last bit is run by devenv. Yet each launch is always in the VS debugger.


357 0.11112275 KaleidoscopeApp IRP_MJ_CREATE Serial4 SUCCESS Options:
Open
358 0.00000305 KaleidoscopeApp IOCTL_SERIAL_GET_PROPERTIES Serial4 SUCCESS
...

406 0.02997366 KaleidoscopeApp IRP_MJ_CLEANUP Serial4 SUCCESS
407 0.03390231 KaleidoscopeApp IRP_MJ_CLOSE Serial4 SUCCESS
408 0.11443431 KaleidoscopeApp IRP_MJ_CREATE Serial4 SUCCESS Options:
Open
409 0.00000727 KaleidoscopeApp IOCTL_SERIAL_GET_PROPERTIES Serial4 SUCCESS
...

457 0.02995160 KaleidoscopeApp IRP_MJ_CLEANUP Serial4 SUCCESS
458 0.03389956 KaleidoscopeApp IRP_MJ_CLOSE Serial4 SUCCESS
459 0.11307261 devenv.exe IRP_MJ_CREATE Serial4 SUCCESS Options:
Open
460 0.00000185 devenv.exe IOCTL_SERIAL_GET_PROPERTIES Serial4 SUCCESS
...

501 35.55274341 devenv.exe IOCTL_SERIAL_WAIT_ON_MASK Serial4 CANCELLED


Any insight would be appreciated!

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

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

发布评论

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

评论(1

别靠近我心 2024-08-24 14:16:12

上周我在使用 VS2008 和 VS2010 时遇到了完全相同的问题。修复此问题的一种方法是从解决方案文件夹中删除 .suo 文件。

VS 这样做的原因是什么?为什么它存储在 .suo 文件中?我不知道...

I've had exactly the same problem these last weeks, with VS2008 and VS2010. One way to fix it is to delete the .suo file from the solution folder.

For which reason VS is doing that, and why it's stored in the .suo file? I don't know...

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