Тест HandleProcessCorruptedStateExceptions
особенность:
using System.Diagnostics;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
...
[HandleProcessCorruptedStateExceptions]
public void HandleCorruptedStateException()
{
try
{
var ptr = new IntPtr(42);
Marshal.StructureToPtr(42, ptr, true);
}
catch(Exception ex)
{
Debug.WriteLine(ex.Message);
}
}