重现应用程序退出后仍在运行的MSACCESS.EXE进程 [英] Reproduce MSACCESS.EXE process still running after application exit

查看:249
本文介绍了重现应用程序退出后仍在运行的MSACCESS.EXE进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时访问将无法完全退出,并且使MSACCESS.EXE进程运行时没有可见的用户界面(该应用程序不再显示在任务管理器的应用程序选项卡中。)

Access will sometimes fail to exit cleanly and leave an MSACCESS.EXE process running with no visible user interface (the application is no longer shown in the Applications tab of Task Manager).

重现此错误所需的最少代码是什么?

What is the minimal code necessary to reproduce this error?

UPDATE :我已经发布了一个可以可靠地重现该问题的答案。我对可能也会重现该问题的其他情况非常感兴趣。 我将对以后能成功重现该问题的所有答案进行投票。我想将此问题存储为导致该问题的经过验证的方案的存储库,以便将来遇到此问题的人得到更好的解释。然后通常会含糊地建议关闭所有打开的对象等。

UPDATE: I've posted an answer that reliably reproduces the problem. I would be very interested in other scenarios that may also reproduce the issue. I will upvote any future answer that successfully reproduces the problem. I would like to make this question a repository of verified scenarios that cause the issue so that those who run into this problem in the future have a better explanation then the usual vague suggestions to "close all open objects, etc."

推荐答案

我一直在高低搜寻这种现象的可再现示例,最后偶然发现布里斯班的Chris发布了这个答案,澳大利亚:有些微妙的事情……我在这里稍加修改地重新发布了他的答案:

I've searched high and low for a reproducible example of this phenomenon and finally stumbled upon this answer posted by Chris from Brisbane, Australia: Something a little more subtle... I'm reposting his answer here with very slight modification:

创建新表单并添加一个名为 cmdShutdown 使用以下代码:

Create a new form and add a single command button named cmdShutdown with the following code:

Dim PersistentRS As DAO.Recordset

Private Sub Form_Open(Cancel As Integer)
    Set PersistentRS = CurrentDb.OpenRecordset("SELECT * FROM msysobjects")
End Sub

Private Sub cmdShutdown_Click()
    Application.Quit            ' < This is the culprit.
End Sub

Private Sub Form_Close()
    On Error GoTo ErrorHandler
ExitProcedure:
    PersistentRS.Close    ' < This is all it requires.
    Exit Sub
ErrorHandler:
    Resume ExitProcedure
End Sub

此问题不是与PersistentRecordset保持打开状态相反,相反。
事实是垃圾收集器已经完成了工作,并且已经关闭了PersistentRecordset。

This problem is not about the PersistentRecordset being left open, quite the contrary. The fact is that the garbage collector has done its job and has already closed PersistentRecordset.

应用程序调用了垃圾收集器。退出Form_Close事件之前

The garbage collector was called by Application.Quit before the Form_Close event was called.

任何应用程序。退出命令将调用垃圾收集器,并且该命令是否在另一个窗体上也没有关系。

Any Application.Quit command will call the garbage collector and it doesn’t matter if that command is on another Form.

一旦Application.Quit命令调用了垃圾收集器,所有变量都将被重置。
然后,Application.Quit命令启动关闭序列。
如果打开了任何窗体,则尝试将其关闭。
如果窗体具有Form_Close或Form_Unload事件,则将触发这些事件。
当由Application.Quit命令调用时,这些事件正在使用已经关闭的PersistentRecordset运行。

Once the Application.Quit command has called the garbage collector all variables have been reset. The Application.Quit command then starts a shutdown sequence. If any Form is open then an attempt is made to close it. If the Form has a Form_Close or Form_Unload event those events will fire. When invoked by the Application.Quit command those events are running with PersistentRecordset which has already been closed.

因此,如果要查找哪个记录集,尚未关闭,然后节省一些时间。查找试图关闭它们并删除该尝试的记录集。
我们为垃圾收集器支付了很多钱,所以我们应该使用它;有用。
尝试自己执行垃圾回收会导致失败。

So, if you are going to look for recordsets which have not been closed then save yourself some time. Look for recordsets where an attempt is made to close them and remove that attempt. We paid good money for the garbage collector so we should use it; it works. Trying to do the garbage collection ourselves can lead to failure.

但是任何此类循环错误,而不仅仅是记录集错误,都会导致Access太忙而无法关闭。

But any such circular error, not just recordset errors, will cause Access to be too busy to close.

克里斯。

我确认这再现了Windows 7 64位中运行的Access 2002中出现错误。

I confirmed this reproduces the error in Access 2002 running in Windows 7 64-bit.

这篇关于重现应用程序退出后仍在运行的MSACCESS.EXE进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆