如何消除第 3 方应用程序产生的未处理的异常对话框
我正在使用无法重新编译的第三方可执行文件(供应商不再可用)。它最初是在 .Net 1.1 下编写的,但似乎在更高版本下也能正常工作。我从我自己的应用程序中使用 Process.Start 启动它(我也尝试过 p/invoke CreateProcess ,结果相同,所以这不相关)
不幸的是,这个第 3 方应用程序现在在退出时抛出未处理的异常。 Microsoft 对话框的标题类似于“从 v2.0 抛出异常...广播窗口”,其中包含与其运行的 .Net 版本相关的版本号(我可以使用 .exe.config 文件来定位不同的 .Net版本,没有帮助)。
退出时未处理的异常对话框不会导致任何实际问题,但对我的用户来说很麻烦,他们每次都必须单击“确定”来关闭它。有没有什么方法(也许是配置文件选项)来禁用此对话框,使其无法为我没有源代码的应用程序显示?我考虑过将其加载到新的 AppDomain 中,这将使我能够访问 UnhandledException 事件,但没有迹象表明我可以更改对话框的外观。也许有人知道导致异常的原因,我可以通过其他方式解决这个问题吗?
I'm working with a 3rd party executable that I can't recompile (vendor is no longer available). It was originally written under .Net 1.1 but seems to work fine under later versions as well. I launch it using Process.Start from my own application (I've tried p/invoke CreateProcess as well with the same results so that's not relevant)
Unfortunately this 3rd party app now throws an unhandled exception as it exits. The Microsoft dialog box has a title like "Exception thrown from v2.0 ... Broadcast Window" with the version number relating to the version of .Net it's running under (I can use a .exe.config file to target different .Net versions, doesn't help).
The unhandled exception dialog box on exit doesn't cause any real problems, but is troubling to my users who have to click OK to dismiss it every time. Is there any way (a config file option perhaps) to disable this dialog from showing for an app I don't have the source code to? I've considered loading it in a new AppDomain which would give me access to the UnhandledException event but there's no indication I could change the appearence of the dialog. Maybe someone knows what causes the exception and I can fix this some other way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以编写一个直接调用第 3 方应用程序的包装应用程序,并使用 Process.Start 启动您的应用程序。
然后在包装应用程序中捕获异常,以便用户不会看到错误消息。
You could write a wrapper application that calls the 3rd party application directly and launch your application using
Process.Start
.Then in your wrapper application trap the exception so the users won't see the error message.
如果没有混淆的话可以反编译吗?这当然是非法的,但如果公司真的破产了,那么就没有人追究了。如果你别无选择,你支持该代码也是合理的。
Reflector 可能会为您提供有关代码崩溃原因的线索,也许您需要执行某些操作或使用参数调用它来阻止它这样做?
If it hasn't been obfuscated you may be able to decompile it? This is of course illegal etc. but if the company has actually gone bankrupt then no one is there to pursue it. It is reasonable for you to support the code if you have no other choice.
Reflector might give you a clue as to why the code crashes as well, perhaps you need to do something or call it with a parameter to stop it from doing so?
下次不要尝试使用没有源代码的东西:)
解决方法是遵循 Chris 的建议。包装应用程序可以使用这样的代码,
http: //blog.jtbworld.com/2007/06/windows-live-writer-spell-checking.html
http://msdn.microsoft.com/en-us/库/system.appdomain.unhandledException.aspx
Next time don't try to use something without source code :)
A workaround is to follow Chris' suggestion. A wrapper application can make use of such code,
http://blog.jtbworld.com/2007/06/windows-live-writer-spell-checking.html
http://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception.aspx