SetCompatibilitySwitches Method
Collapse the table of content
Expand the table of content
This documentation is archived and is not being maintained.

AppDomainSetup.SetCompatibilitySwitches Method

Sets the specified switches, making the application domain compatible with previous versions of the .NET Framework for the specified issues.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public void SetCompatibilitySwitches(
	IEnumerable<string> switches


Type: System.Collections.Generic.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 version 4 introduces a small number of breaking changes from the .NET Framework version 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.




Code access security (CAS) for the .NET Framework 3.5 is enabled in this application domain. See <NetFx40_LegacySecurityPolicy> Element.


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.


TimeSpan formatting behavior for the .NET Framework 3.5 is enabled in this application domain.

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
© 2016 Microsoft