Delphi DLL 异常关闭我的应用程序
我在 Delphi 2010 应用程序中加载了 Delphi 2010 DLL。它在大多数时间都工作得很好。但是有一些异常从 DLL 中逃逸(即使是那些由 try..except
块处理的异常),并且我的应用程序崩溃,没有错误消息,根本没有任何信息。我所说的异常就像AV,而不是开发者提出的异常。我尝试使用 SafeLoadLibrary 加载 DLL,但没有成功。我还有应用程序和 DLL 源代码。我不会发布 DLL 或应用程序源代码,因为我不能,它们受版权保护(我真的希望我可以)。
我可以采取什么措施来避免内部 DLL 异常导致应用程序崩溃?
编辑
我无法阻止 DLL 引发异常。这种情况是有可能发生的,并不是所有的代码都是完美的。 dll 引发异常可能是不可避免的,但它不应该使主应用程序崩溃。例如,假设您正在使用没有源代码的第三方 dll。当这个 dll 由于某种原因崩溃时,你的主应用程序被杀死,这不是一件好事。它必须有办法不允许这种情况发生。
I have a Delphi 2010 DLL loaded in a Delphi 2010 app. It works fine for the most of the time. But there are some exceptions that escapes from the DLL (even those that are treated by a try..except
block) and my application crash with no error message, no information at all. The exceptions what I am talking about are like AV, not like the exceptions raised by the developer. I have tried loading the DLL with SafeLoadLibrary
without luck. I also have the app and DLL source code. I am not posting the DLL or the app source code because I can't, they are copyrighted (I really wish I could).
Is there anything I can do to avoid an internal DLL exception to crash my app?
EDIT
I have no way of not allowing the DLL to raise an exception. It can happens, not all codes are perfect. It may be inevitable that the dll raises an exception, but it should not crash the main app. Imagine, for example, that you are using a third party dll which you have no source code. Its not a good thing that when this dll crashs for some reason your main app get killed. It must have an way of not allowing that to happen.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你所要求的是不可能的。 DLL 与执行进程共享相同的内存空间。因此,任何一个都可能导致应用程序崩溃。
您的想法确实正确,因为您的 DLL 需要做它能做的事情。它需要成为应用程序进程空间中的好公民。
有些事情你可以做来变得友善。
What you are asking for is not possible. DLL's share the same memory space as the executing process. As such either can do things to cause the application to crash.
You do have the correct idea, in that your DLL needs to do what it can. It needs to be a good citizen in the application process space.
Some things you can do to be nice.