Clemens Vasters - Are you catching falling knives?里給了一個判斷C#的exception是不是fatal的代碼,可以參考參考。
public static bool IsFatal(this Exception exception) {while (exception != null){if (exception as OutOfMemoryException != null && exception as InsufficientMemoryException == null || exception as ThreadAbortException != null || exception as AccessViolationException != null || exception as SEHException != null || exception as StackOverflowException != null){return true;}else{if (exception as TypeInitializationException == null && exception as TargetInvocationException == null){break;}exception = exception.InnerException;}}return false; }