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. 若要清除設定,請 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" 在此應用程式域中,已啟用 .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 格式」一節 TimeSpanSee <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.

適用於

另請參閱