gpt4 book ai didi

c# - 在自己的文件夹中检测丢失的 Dll

转载 作者:行者123 更新时间:2023-11-30 17:01:37 28 4
gpt4 key购买 nike

我试图阻止我的程序收到任何错误消息。到目前为止,我尝试使用 try 语句来检测我的错误。但是当我尝试将 Dll 从我的应用程序移动到另一个文件夹时。框架错误首先发生,虽然框架给我一个特定的错误,但我的目标是创建我自己的错误消息。

enter image description here

最佳答案

您可以尝试使用 HandleProcessCorruptedStateExceptionsAttribute但是您必须确保您的进程在捕获到这些异常后处于稳定 状态。使用 AppDomain.CurrentDomain.UnhandledException 在应用程序级别处理异常也是一种很好的做法。但这只会捕获那些可以由 try-catch block 处理的异常。

Corrupted process state exceptions are exceptions that indicate that the state of a process has been corrupted. We do not recommend executing your application in this state. By default, the common language runtime (CLR) does not deliver these exceptions to managed code, and the try/catch blocks (and other exception-handling clauses) are not invoked for them. If you are absolutely sure that you want to maintain your handling of these exceptions, you must apply the HandleProcessCorruptedStateExceptionsAttribute attribute to the method whose exception-handling clauses you want to execute. The CLR delivers the corrupted process state exception to applicable exception clauses only in methods that have both the HandleProcessCorruptedStateExceptionsAttribute and SecurityCriticalAttribute attributes, MSDN.

关于c# - 在自己的文件夹中检测丢失的 Dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20851612/

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