Delphi - 具有 ActiveX 控件的应用程序会导致“应用程序崩溃”
我必须使用 ActiveX 对象 (QlikOCX.ocx)。因此,我创建了一个非常小的示例应用程序,它工作正常,但是当我关闭该应用程序时,我收到如下错误:
“application.exe 不再工作 ->在线搜索解决方案并关闭程序 ->关闭程序
问题详细信息: 问题事件名称:APPPCRASH ...”
我想知道是否可以通过某种方式捕捉到这个错误? 谢谢你!
I have to use an ActiveX Object (QlikOCX.ocx). So I've created a very small sample application, which works fine, but when I close the application I get an error like this:
"application.exe doesn't work anymore
-> Search online for an solution and close the programm
-> Close the programm
Problem details:
Problem-event-name: APPCRASH
..."
I want to know if it is possible to catch this error in some way?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您收到的错误可能有多种原因。这可能是您自己的代码或 ActiveX 控件中的问题。例如,您的进程可能会终止,但其中一个线程仍在运行,轮询信息或执行其他操作。
很可能您没有正确释放 ActiveX 控件,从而导致留下一些未完成的事务。在调试器中运行应用程序可以为您提供错误的位置,但情况可能会更复杂一些。有时,糟糕的事情就发生了...
您是否创建了一个小型控制台应用程序来测试此 OCX?或者您是否将其作为组件导入并将其添加到表单中?
对于控制台应用程序,请确保您没有使用全局变量来存储 OCX 对象!全局接口对象并不总是正确释放。
如果在表单上使用组件,请在此表单上添加 OnClose 事件,并在此事件中添加应清理 OCX 控件的代码。不要释放它,而是查看它是否有“关闭”、“清除”或“终止”函数或其他需要调用的清理方法。再次强调,不要对 OCX 控件等基于接口的类型使用全局变量。
The error you get can have a lot of causes. It could be a problem in your own code or in the ActiveX control. For example, your process might terminate, yet one of the threads is still running, polling for information or whatever.
Chances are that you don't free the ActiveX control correctly, thus causing something that leaves some unfinished business behind. Running your application within the debugger could provide you the location of the error but chances are that it's a bit more complicated. Sometimes, sh*t just happens...
Did you create a small console application to test this OCX? Or did you import it as a component and did you add it to a form?
In the case of a console application, make sure you're not using a global variable to store the OCX object! Global interfaced objects aren't always released correctly.
If using a component on a form, add an OnClose event on this form and add code in this event that should clean up the OCX control. Don't free it, but see if it has a "Close", "Clear" or "Terminate" function or other cleanup method that needs to be called. And again, don't use global variables for interface-based types like OCX controls.
尝试在退出应用程序之前调用 ActiveX.CoFreeUnusedLibraries。如果您使用 Delphi 7.1 之前的版本,请参阅质量中心报告#:3272 ,有一个错误。
Try to call ActiveX.CoFreeUnusedLibraries before exiting the application. If you use Delphi earlier then 7.1 then see Quality Central Report#:3272, there was a bug.