AppDomainSetup.SetCompatibilitySwitches(IEnumerable<String>) 方法
定义
设置指定的开关,从而使应用程序域针对指定问题与早期版本的 .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>
指定兼容性开关的字符串值的可枚举集或要擦除现有兼容性开关的 null。An 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 3.5 引入了少量的重大更改。For example, the .NET Framework 4 introduces a small number of breaking changes from the .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. 若要清除设置,请 null 为 switches 参数指定。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" | 在此应用程序域中启用了 .NET Framework 3.5 (CAS) 的代码访问安全性。Code access security (CAS) for the .NET Framework 3.5 is enabled in this application domain. 请参阅 < NetFx40_LegacySecurityPolicy > 元素。See <NetFx40_LegacySecurityPolicy> Element. |
| "NetFx40_Legacy20SortingBehavior""NetFx40_Legacy20SortingBehavior" | 在此应用程序域中启用 .NET Framework 3.5 的字符串排序默认值。String sorting defaults for the .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 和 Unicode 5.0 的字符串排序默认值。String sorting defaults for the .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 的格式设置行为。TimeSpan formatting behavior for the .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. |
适用于
另请参阅
- IsCompatibilitySwitchSet(String)
- <NetFx40_LegacySecurityPolicy > 元素<NetFx40_LegacySecurityPolicy> Element
- <CompatSortNLSVersion > 元素<CompatSortNLSVersion> Element
- <TimeSpan_LegacyFormatMode > 元素<TimeSpan_LegacyFormatMode> Element
- <UseRandomizedStringHashAlgorithm > 元素<UseRandomizedStringHashAlgorithm> Element