<NetFx40_LegacySecurityPolicy> Element

.NET Framework (current version)
 

Specifies whether the runtime uses legacy code access security (CAS) policy.

<configuration>
<runtime>
<NetFx40_LegacySecurityPolicy>

<NetFx40_LegacySecurityPolicy  
   enabled="true|false"/>  

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

Attributes

AttributeDescription
enabledRequired attribute.

Specifies whether the runtime uses legacy CAS policy.
ValueDescription
falseThe runtime does not use legacy CAS policy. This is the default.
trueThe runtime uses legacy CAS policy.

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 runtime initialization options.

In the .NET Framework version 3.5 and earlier versions, CAS policy is always in effect. In the .NET Framework 4, CAS policy must be enabled.

CAS policy is version-specific. Custom CAS policies that exist in earlier versions of the .NET Framework must be respecified in the .NET Framework 4.

Applying the <NetFx40_LegacySecurityPolicy> element to a .NET Framework 4 assembly does not affect security-transparent code; the transparency rules still apply.

System_CAPS_ICON_important.jpg Important

Applying the <NetFx40_LegacySecurityPolicy> element can result in significant performance penalties for native image assemblies created by the Native Image Generator (Ngen.exe) that are not installed in the global assembly cache. The performance degradation is caused by the inability of the runtime to load the assemblies as native images when the attribute is applied, resulting in their being loaded as just-in-time assemblies.

System_CAPS_ICON_note.jpg Note

If you specify a target .NET Framework version that is earlier than the .NET Framework 4 in the project settings for your Visual Studio project, CAS policy will be enabled, including any custom CAS policies you specified for that version. However, you will not be able to use new .NET Framework 4 types and members. You can also specify an earlier version of the .NET Framework by using the <supportedRuntime> element in the startup settings schema in your application configuration file.

System_CAPS_ICON_note.jpg Note

Configuration file syntax is case-sensitive. You should use the syntax as provided in the Syntax and Example sections.

This element can be used only in the application configuration file.

The following example shows how to enable legacy CAS policy for an application.

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

Runtime Settings Schema
Configuration File Schema

Show: