AppDomainSetup.SetCompatibilitySwitches(IEnumerable<String>) 方法

定義

針對指定的問題來設定指定的參數,讓應用程式定義域與舊版 .NET Framework 相容。

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 以清除現有的相容性參數。

備註

.NET Framework的主要版本有時會從舊版引進重大變更。 例如,.NET Framework 4 從 .NET Framework 3.5 引進少量的重大變更。 SetCompatibilitySwitches使用 方法來指定應用程式域應復原其中一或多個重大變更,使行為與舊版.NET Framework相容。

每次呼叫此方法時,都會取代現有的參數設定。 若要清除設定,請為 switches 參數指定 null

您提供給 switches 的字串值集合可以是簡單的字串陣列,因為陣列會實作 IEnumerable 介面。

下表提供相容性參數的範例,可設定為還原舊版.NET Framework的行為。

交換器 意義
「NetFx40_LegacySecurityPolicy」 此應用程式域中已啟用 .NET Framework 3.5 的程式碼存取安全性 (CAS) 。 請參閱 < NetFx40_LegacySecurityPolicy > 元素
「NetFx40_Legacy20SortingBehavior」 此應用程式域中已啟用.NET Framework 3.5 的字串排序預設值。 成功還原舊版排序行為也需要本機系統上提供sort00001000.dll動態連結程式庫。 請參閱 < CompatsortNLSVersion > 元素
「NetFx40_Legacy40SortingBehavior」 此應用程式域中會啟用 .NET Framework 4 和 Unicode 5.0 的字串排序預設值。 成功還原舊版排序行為也需要本機系統上提供sort00060101.dll動態連結程式庫。
「NetFx40_TimeSpanLegacyFormatMode」 TimeSpan此應用程式域中已啟用.NET Framework 3.5 的格式行為。 See <TimeSpan_LegacyFormatMode> Element and the "Restoring Legacy TimeSpan Formatting" section of the TimeSpan topic.
「UseRandomizedStringHashAlgorithm」 執行時間會根據每個應用程式域計算字串的雜湊碼,而不是使用單一雜湊演算法,在應用程式域之間產生一致的雜湊程式碼。 請參閱 < UseRandomizedStringHashAlgorithm > 元素

適用於

另請參閱