AppDomainSetup.SetCompatibilitySwitches(IEnumerable<String>) AppDomainSetup.SetCompatibilitySwitches(IEnumerable<String>) AppDomainSetup.SetCompatibilitySwitches(IEnumerable<String>) AppDomainSetup.SetCompatibilitySwitches(IEnumerable<String>) Method

定义

设置指定的开关,从而使应用程序域针对指定问题与早期版本的 .NET Framework 兼容。Sets the specified switches, making the application domain compatible with previous versions of the .NET Framework for the specified issues.

public:
 void SetCompatibilitySwitches(System::Collections::Generic::IEnumerable<System::String ^> ^ switches);
public void SetCompatibilitySwitches (System.Collections.Generic.IEnumerable<string> switches);
member this.SetCompatibilitySwitches : seq<string> -> unit
Public Sub SetCompatibilitySwitches (switches As IEnumerable(Of String))

参数

switches
IEnumerable<String>

指定兼容性开关的字符串值的可枚举集或要擦除现有兼容性开关的 nullAn enumerable set of string values that specify compatibility switches, or null to erase the existing compatibility switches.

注解

主要版本的.NET Framework 的先前版本中,有时会引入重大更改。Major versions of the .NET Framework sometimes introduce breaking changes from the previous version. 例如,.NET Framework 4.NET Framework 4引入了少量的重大更改从 .NET Framework 3.5.NET Framework 3.5For example, the .NET Framework 4.NET Framework 4 introduces a small number of breaking changes from the .NET Framework 3.5.NET Framework 3.5. 使用SetCompatibilitySwitches方法,以指定一个或多个这些重大更改应回滚应用程序域,以使此行为与以前版本的.NET framework 兼容。Use the SetCompatibilitySwitches method to specify that one or more of these breaking changes should be rolled back for the application domain, to make the behavior compatible with the previous version of the .NET Framework.

每次调用此方法,它将替换现有的交换机设置。Each time you call this method, it replaces the existing switch settings. 若要清除设置,指定nullswitches参数。To erase the settings, specify null for the switches parameter.

为提供的字符串值的一套switches可以是简单的字符串数组,因为数组实现IEnumerable接口。The set of string values you provide for switches can be a simple string array, because arrays implement the IEnumerable interface.

下表提供了兼容性开关,可设置为还原的早期版本的.NET Framework 的行为的示例。The following table provides examples of compatibility switches that can be set to restore the behavior of earlier versions of the .NET Framework.

开关Switch 含义Meaning
"NetFx40_LegacySecurityPolicy""NetFx40_LegacySecurityPolicy" 有关代码访问安全性 (CAS).NET Framework 3.5.NET Framework 3.5启用此应用程序域中。Code access security (CAS) for the .NET Framework 3.5.NET Framework 3.5 is enabled in this application domain. 请参阅 <NetFx40_LegacySecurityPolicy>元素See <NetFx40_LegacySecurityPolicy> Element.
"NetFx40_Legacy20SortingBehavior""NetFx40_Legacy20SortingBehavior" 字符串排序的默认值.NET Framework 3.5.NET Framework 3.5在此应用程序域中启用。String sorting defaults for the .NET Framework 3.5.NET Framework 3.5 are enabled in this application domain. 已成功还原旧的排序行为还要求 sort00001000.dll 动态链接库在本地系统上可用。Successfully restoring legacy sorting behavior also requires the sort00001000.dll dynamic link library to be available on the local system. 请参阅 <CompatSortNLSVersion>元素See <CompatSortNLSVersion> Element.
"NetFx40_Legacy40SortingBehavior""NetFx40_Legacy40SortingBehavior" 字符串排序的默认值.NET Framework 4.NET Framework 4,并且在此应用程序域中启用 Unicode 5.0。String sorting defaults for the .NET Framework 4.NET Framework 4 and Unicode 5.0 are enabled in this application domain. 已成功还原旧的排序行为还需要为本地系统上可用的 sort00060101.dll 动态链接库。Successfully restoring legacy sorting behavior also requires the sort00060101.dll dynamic link library to be available on the local system.
"NetFx40_TimeSpanLegacyFormatMode""NetFx40_TimeSpanLegacyFormatMode" TimeSpan 格式设置行为的.NET Framework 3.5.NET Framework 3.5启用此应用程序域中。TimeSpan formatting behavior for the .NET Framework 3.5.NET Framework 3.5 is enabled in this application domain. 请参阅 <TimeSpan_LegacyFormatMode>元素和"还原旧版 TimeSpan 格式设置"部分的TimeSpan主题。See <TimeSpan_LegacyFormatMode> Element and the "Restoring Legacy TimeSpan Formatting" section of the TimeSpan topic.
"UseRandomizedStringHashAlgorithm""UseRandomizedStringHashAlgorithm" 在运行时计算字符串的哈希代码对每个应用程序域而不是使用跨应用程序域生成一致的哈希代码的单个哈希算法。The runtime calculates hash codes for strings on a per application domain basis instead of using a single hashing algorithm that produces a consistent hash code across application domains. 请参阅 <userandomizedstringhashalgorithm,那么>元素See <UseRandomizedStringHashAlgorithm> Element.

适用于

另请参阅