我知道我以前有过这种情况,但我不记得如何解决它。
我构建了一个托管代码加载项,除了一件事之外它工作得很好。当我尝试关闭 Access 应用程序时,应用程序窗口仍然存在,除非我结束它的任务。当我使用 Visual Studio 2010 调试加载项时,它会在我停止调试时正常关闭。
作为断开连接事件的一部分,我将所有变量设置为空。
Public Sub OnDisconnection(ByVal RemoveMode As Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnDisconnection
'On Error Resume Next
If Not MenuCommandControls Is Nothing Then MenuCommandControls.Delete()
If Not MenuCommandDimensionVariable Is Nothing Then MenuCommandDimensionVariable.Delete()
If Not MenuCommandFields Is Nothing Then MenuCommandFields.Delete()
If Not MenuCommandForms Is Nothing Then MenuCommandForms.Delete()
If Not MenuCommandParseSQL Is Nothing Then MenuCommandParseSQL.Delete()
If Not MenuCommandQueries Is Nothing Then MenuCommandQueries.Delete()
If Not MenuCommandReports Is Nothing Then MenuCommandReports.Delete()
If Not MenuCommandTables Is Nothing Then MenuCommandTables.Delete()
If Not MenuCommandVariables Is Nothing Then MenuCommandVariables.Delete()
If Not searchForm Is Nothing Then searchForm.Close() : searchForm = Nothing
If Not ObjectSetting Is Nothing Then ObjectSetting = Nothing
If Not AccessInst Is Nothing Then AccessInst = Nothing
If Not addInInstance Is Nothing Then addInInstance = Nothing
'If Not FormParseSQL Is Nothing Then FormParseSQL = Nothing
applicationObject.Quit(Access.AcQuitOption.acQuitPrompt)
If Not applicationObject Is Nothing Then applicationObject = Nothing
End Sub