I guess that legacyNullReferencePolicy is renamed in the final bits of .Net 4.0
You are looking for the legacyCorruptedStateExceptionsPolicy setting in the <runtime>
config section like so:
<configuration>
<runtime>
<legacyCorruptedStateExceptionsPolicy enabled="true" />
</runtime>
</configuration>
or decorate your method that needs to handle those state corruption exceptions with this attribute:HandleProcessCorruptedStateExceptionsAttribute:
This example is taken from this msdn article in the CLR Inside Out series of author Andrew Pardoe
[HandleProcessCorruptedStateExceptions]
[SecurityCritical]
public static int Main()
{
try
{
// Catch any exceptions leaking out of the program
}
catch (Exception e)
// We could be catching anything here
{
System.Console.WriteLine(e.Message);
return 1;
}
return 0;
}