我以前看过这样的错误,但通常它说哪个组件缺少依赖关系或没有正确注册.
我通过进程监视器运行它,并获得它找不到的以下文件:
然后就退出了.我搜索了它找不到的文件名,似乎找不到任何东西.它似乎是搜索了MSComENU,MSComEN和MSCOENU dll的变体.
我检查并重新检查,以确保所有的第三方组件都在那里,他们是 – 应用程序功能正常,如果他们不在那里不会.
值得注意的是,在VB6代码(在Form_Unload事件中)的最后一行被触发后,会发生错误.我知道这是因为最后一行是出现的消息框.
很多时候,编辑:我终于回到了处理这个问题,并通过消除过程来解决(这是一个很糟糕的过程).最终它与任何MSCOMM * .dll条目无关.事实上,我不知道为什么它们仍然显示在Process Monitor中.问题要简单得多
我在主窗体上有几个第三方控制.为了不用大量事件处理代码来污染主窗体,我将这些控件委托给一个新类,如下所示:
' declaration code in main form' Private WithEvents moDelegateObject as clsDelegateObject ' still in the main form,after initialization' Set moDelegateObject = new clsDelegateObject With moDelegateObject Set .ThirdPartyCtlHandler1 = me.ThirdPartyCtl1 Set .ThirdPartyCtlHandler2 = me.ThirdPartyCtl2 Set .ThirdPartyCtlHandler3 = me.ThirdPartyCtl3 end with ' declarations and properties inside of clsDelegateObject' Private WithEvents moThirdPartyCtlHandler1 as ThirdPartyCtl Private WithEvents moThirdPartyCtlHandler2 as ThirdPartyCtl Private WithEvents moThirdPartyCtlHandler3 as ThirdPartyCtl Public Event FooEvent() ' other varIoUs events as well ' Public Property Set ThirdPartyCtlHandler1(o as ThirdPartyCtl) moThirdPartyCtlHandler1 = o End Property Public Property Get ThirdPartyCtlHandler1() as ThirdPartyCtl ThirdPartyCtlHandler1 = moThirdPartyCtlHandler1 End Property ' ... Repeat for each handler ...'
缺少的是在关闭之前明确地释放这些对象的代码.这是Visual Basic通常所做的.所以我在Form_QueryClose中添加了以下主窗体:
With moDelegateObject Set .ThirdPartyCtlHandler1 = Nothing Set .ThirdPartyCtlHandler2 = Nothing Set .ThirdPartyCtlHandler3 = Nothing End with Set moDelegateObject = Nothing
最后一行竟然是超凡的,但是我把它丢在了那里,是为了完整的.我认为这是将委托委托给代理类并从主窗体中接收事件的组合,并使用了许多真正晦涩的第三方控件来帮助这个问题.第三方控制很可能不会自动释放.无论如何,吸取教训.