Gracefully handling corrupted state exceptions in .NET Core
问题 I have basically a duplicate question but for .NET Core. I have Core console app: class Program { static void DoSomeAccessViolation() { // if you have any questions about why this throws, // the answer is "42", of course var ptr = new IntPtr(42); Marshal.StructureToPtr(42, ptr, true); } [SecurityCritical] [HandleProcessCorruptedStateExceptions] static void Main(string[] args) { try { DoSomeAccessViolation(); } catch (Exception ex) { Console.Error.WriteLine(ex); } } } I've tried to add a