调试 SHDocVw.InternetExplorer.Quit 不关闭 iexplore.exe 进程
我认为没有明确的答案,那么您将如何解决这个问题?:
我的主应用程序(一个 MicroStation 插件)使用 SHDocVw.InternetExplorer COM 包装器启动 IE,与其交互,在不使用时隐藏它(例如,在用户关闭窗口并将 InternetExplorer.Visible 设置为 false)。
当主应用程序关闭时,插件通过调用 InternetExplorer.Quit 来关闭 IE,但 iexplore 进程仍保持运行(IE 在主应用程序关闭时隐藏)。
我尝试过的操作:
- 调用 Quit 后在 InternetExplorer 对象上调用 System.Runtime.InteropServices.Marshal.FinalReleaseComObject
- 在 Quit 和 FinalReleaseComObject 后将对 InternetExplorer 对象的引用设置为 null
- 确保父托管对象得到 GC(检查 Finalize 是否为在主应用程序退出之前
- 创建一个测试控制台应用程序并尝试在那里重现问题。例如,当 IE 处于隐藏状态时尝试调用 Quit。 (我无法重现该问题,应用程序退出后 IE 就会关闭)
同样有趣的是,我无法重现在同一个主应用程序(MicroStation 插件)中调用 Quit 的问题,但是当主应用程序正在运行时,而不是在退出事件处理代码。当在其他地方调用 Quit 时,会按预期关闭 IE。
否则 InternetExplorer 对象对我来说是不透明的。
还有其他方法可以调试这个问题吗?
编辑:可能值得注意的是,主应用程序创建了一个 UserControl 并使 IE 窗口成为该 UserControl 的子窗口(使用 SetWindowLong 更改 GWL_STYLE 以允许窗口成为子窗口,并使用 SetParent 设置UserControl 作为父级)。但是当 IE 隐藏时(退出尝试失败时),父窗口将设置为 0。
谢谢!
I think there's no definite answer so how would you approach debugging this problem?:
My main app (a MicroStation plugin) launces IE using the SHDocVw.InternetExplorer COM wrapper, interacts with it, hides it when it is not used (e.g. intercepts when the user closes the window and sets InternetExplorer.Visible to false).
When the main app is closed the plugin closes IE by calling InternetExplorer.Quit but the iexplore process is left running (the IE is hidden at the moment the main app is closed).
What I have tried:
- Calling System.Runtime.InteropServices.Marshal.FinalReleaseComObject on the InternetExplorer object after calling Quit
- Setting the reference to the InternetExplorer object to null after Quit and FinalReleaseComObject
- Making sure the parent managed objects gets GC'd (checking if Finalize is called) before the main app exits
- Creating a test console app and trying to reproduce the problem there. E.g. trying to call Quit when IE is in the hidden state. (I could not reproduce the problem, IE gets closed as soon as the app exits)
What is also interesting, I could not reproduce the problem calling Quit within the same main app (MicroStation plugin) but while the main app is running, not in the exit event handling code. When called in that other place Quit closes IE as expected.
Otherwise the InternetExplorer object is opaque to me.
Are there other ways to debug this problem?
Edit: It may be worth noting that the main app creates a UserControl and makes the IE window a child of this UserControl (using SetWindowLong to change the GWL_STYLE to allow the window to be a child and SetParent to set the UserControl as parent). But when the IE is hidden (which it is when the Quit attempt fails) the parent window is set to 0.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论