In. Net 4.0, the exception level is handled. exceptions that cause system crashes cannot be eaten.
 
 
 
Specified upted state exceptions
 
 
 
Since 4.0, CLR will not take the initiative to throw you all exceptions. For those exceptions that it deems dangerous and may cause a process crash, it will be marked as uptedstateexception and handled by itself rather than thrownProgramSuch as accessviolationexception, which inherits from systemexception, will be treated as corruptedstateexception. However, it should be noted that only the exception type may be dangerous and the CLR will judge the owner of the thrown exception, if it finds that the access conflict is thrown by the operating system, it will be considered as a State crash exception, but if the exception is caused by the userCodeIf it is thrown, the CLR will not perform special processing on it, and it will still throw it normally as before.
 
 
 
1. If you want to compile the old code in. netframework4.0 but do not want to modify the code, configure the node: legacycorruptedstate -- exceptionspolicy = true
 
 
 
 
 
 
 
 
 
 
 
2 .. net4.0 adds a new namespace: system. runtime. exceptionservices, class handleprocesscorruptedstateexceptionsattribute. You only need to add this attribute to the corresponding method, and CLR will send you all the Exception Processing.
 
 
 
[Handledprocesscorruptedstateexceptions]
 
 
 
Public static int functionname ()
 
 
 
{
 
 
Try
 
 
 
{
 
 
 
// Code maybe throw exception
 
 
 
}
 
 
 
Catch (exception ex)
 
 
 
{
 
 
 
// Can get all the exception
 
 
 
}
 
 
 
}