AppDomainSetup.SetCompatibilitySwitches(IEnumerable<String>) Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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>
An enumerable set of string values that specify compatibility switches, or null
to erase the existing compatibility switches.
Major versions of the .NET Framework sometimes introduce breaking changes from the previous version. For example, the .NET Framework 4 introduces a small number of breaking changes from the .NET Framework 3.5. 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. To erase the settings, specify null
for the switches
parameter.
The set of string values you provide for switches
can be a simple string array, because arrays implement the IEnumerable interface.
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" | Code access security (CAS) for the .NET Framework 3.5 is enabled in this application domain. See <NetFx40_LegacySecurityPolicy> Element. |
"NetFx40_Legacy20SortingBehavior" | String sorting defaults for the .NET Framework 3.5 are enabled in this application domain. Successfully restoring legacy sorting behavior also requires the sort00001000.dll dynamic link library to be available on the local system. See <CompatSortNLSVersion> Element. |
"NetFx40_Legacy40SortingBehavior" | String sorting defaults for the .NET Framework 4 and Unicode 5.0 are enabled in this application domain. Successfully restoring legacy sorting behavior also requires the sort00060101.dll dynamic link library to be available on the local system. |
"NetFx40_TimeSpanLegacyFormatMode" | TimeSpan formatting behavior for the .NET Framework 3.5 is enabled in this application domain. See <TimeSpan_LegacyFormatMode> Element and the "Restoring Legacy TimeSpan Formatting" section of the TimeSpan topic. |
"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. See <UseRandomizedStringHashAlgorithm> Element. |
Product | Versions |
---|---|
.NET Framework | 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: