<legacyCorruptedStateExceptionsPolicy> Element

.NET Framework (current version)
 

Specifies whether the common language runtime allows managed code to catch access violations and other corrupted state exceptions.

<configuration>
<runtime>
<legacyCorruptedStateExceptionsPolicy>

<legacyCorruptedStateExceptionsPolicy enabled="true|false"/>  

The following sections describe attributes, child elements, and parent elements.

Attributes

AttributeDescription
enabledRequired attribute.

Specifies that the application will catch corrupting state exception failures such as access violations.
ValueDescription
falseThe application will not catch corrupting state exception failures such as access violations. This is the default.
trueThe application will catch corrupting state exception failures such as access violations.

Child Elements

None.

Parent Elements

ElementDescription
configurationThe root element in every configuration file used by the common language runtime and .NET Framework applications.
runtimeContains information about assembly binding and garbage collection.

In the .NET Framework version 3.5 and earlier, the common language runtime allowed managed code to catch exceptions that were raised by corrupted process states. An access violation is an example of this type of exception.

Starting with the .NET Framework 4, managed code no longer catches these types of exceptions in catch blocks. However, you can override this change and maintain the handling of corrupted state exceptions in two ways:

  • Set the <legacyCorruptedStateExceptionsPolicy> element's enabled attribute to true. This configuration setting is applied processwide and affects all methods.

-or-

This configuration element is available only in the .NET Framework 4 and later.

The following example shows how to specify that the application should revert to the behavior before the .NET Framework 4, and catch all corrupting state exception failures.

<configuration>  
   <runtime>  
      <legacyCorruptedStateExceptionsPolicy enabled="true" />  
   </runtime>  
</configuration>  

HandleProcessCorruptedStateExceptionsAttribute
Runtime Settings Schema
Configuration File Schema

Show: