在framework框架下,通过添加HandleProcessCorruptedStateExceptionsAttribute属性来解决这个问题,
(.net core1.0到3.1之前,不支持从损坏的进程状态异常中恢复,即try catch 没有防止闪退的作用)
具体可查看MSDN:https://learn.microsoft.com/zh-cn/archive/msdn-magazine/2009/february/clr-inside-out-handling-corrupted-state-exceptions
点击查看代码
[System.Runtime.ExceptionServices.HandleProcessCorruptedStateExceptionsAttribute()]
private void ThirdPartyCall()
{
try
{
return Call3rdPartyFunction()
}
catch (Exception exInstantiate)
{
...
}
}