gpt4 book ai didi

.net - 有没有办法解决 'handle'Environment.FailFast?

转载 作者:行者123 更新时间:2023-12-03 07:45:39 28 4
gpt4 key购买 nike

因此,我们的应用程序有一个很好的中央异常处理程序,其中记录异常的详细信息,向用户显示通用窗口,并以一种优雅的方式关闭。然而,我们现在有一个第三方组件,它时不时地(并且可能出于完全正当的原因)调用Environment.FailFast。这让我们的应用程序陷入困境,并且对我们的用户来说看起来非常糟糕。有没有办法以优雅的方式处理Environment.FailFast?

最佳答案

我看不出有什么办法,根据 MSDN 中的各种条目,这是进程的硬终止。您为处理此问题而创建的任何代码都将驻留在该进程中。它也不会运行finally block 或任何挂起的终结器,所以我猜测不会提供任何事件或 Hook 来允许自定义代码运行。在某种程度上,这是有道理的,否则它可能不会“快速”失败,并且它认为仅在极端进程损坏的情况下使用。

http://msdn.microsoft.com/en-us/library/dd289241

我看到 两个 三个选项:

  1. 向供应商发送请求以更改代码并删除此调用。
  2. 寻找新供应商。
  3. 按照@RB 的建议。将此 DLL 的使用转移到新进程中,以便核心应用程序进程保持安全。我曾经这样做过一次,非常头疼,但“它有效”。 只有当您无法利用建议 1 或 2 时,我才会建议您这样做!

引自MSDN:

This method terminates a process without running any active try/finally blocks or finalizers.

The FailFast method writes the message string to the Windows Application event log, creates a dump of your application, and then terminates the current process. The message string is also included in error reporting to Microsoft.

Use the FailFast method instead of the Exit method to terminate your application if the state of your application is damaged beyond repair, and executing your application's try/finally blocks and finalizers will corrupt program resources.

关于.net - 有没有办法解决 'handle'Environment.FailFast?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10756890/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com