<AppCoNtextSwitchOverrides > 元素<AppContextSwitchOverrides> Element

定義一或多個由 AppContext 類別所使用的參數,以提供新功能的退出機制。Defines one or more switches used by the AppContext class to provide an opt-out mechanism for new functionality.

<configuration> <configuration>
    <runtime >   <runtime>
     <AppCoNtextSwitchOverrides >    <AppContextSwitchOverrides>

語法Syntax

<AppContextSwitchOverrides value="name1=value1[[;name2=value2];...]" />  

屬性和項目Attributes and Elements

下列各節描述屬性、子項目和父項目。The following sections describe attributes, child elements, and parent elements.

屬性Attributes

屬性Attribute 描述Description
value 必要屬性。Required attribute.

定義一或多個參數名稱及其相關聯的布林值。Defines one or more switch names and their associated Boolean values.

value 屬性value Attribute

Value 描述Description
「名稱 = 值」"name=value" 預先定義的參數名稱及其值(truefalse)。A predefined switch name along with its value (true or false). 多個交換器名稱/值組會以分號(";")分隔。Multiple switch name/value pairs are separated by semicolons (";"). 如需 .NET Framework 支援的預先定義參數名稱清單,請參閱備註一節。For a list of predefined switch names supported by the .NET Framework, see the Remarks section.

子項目Child Elements

無。None.

父項目Parent Elements

項目Element 描述Description
configuration 通用語言執行平台和 .NET Framework 應用程式所使用之每個組態檔中的根項目。The root element in every configuration file used by the common language runtime and .NET Framework applications.
runtime 包含有關執行階段初始化選項的資訊。Contains information about runtime initialization options.

備註Remarks

從 .NET Framework 4.6 開始,設定檔中的 <AppContextSwitchOverrides> 元素可讓 API 的呼叫者判斷其應用程式是否可以利用新功能,或保留與舊版程式庫的相容性。Starting with the .NET Framework 4.6, the <AppContextSwitchOverrides> element in a configuration file allows callers of an API to determine whether their app can take advantage of new functionality or preserve compatibility with previous versions of a library. 例如,如果 API 的行為在兩個版本的程式庫之間已變更,<AppContextSwitchOverrides> 元素可讓該 API 的呼叫者選擇不支援新功能之程式庫版本的新行為。For example, if the behavior of an API has changed between two versions of a library, the <AppContextSwitchOverrides> element allows callers of that API to opt out of the new behavior on versions of the library that support the new functionality. 對於在 .NET Framework 中呼叫 Api 的應用程式,<AppContextSwitchOverrides> 元素也可以允許其應用程式以舊版 .NET Framework 為目標的呼叫端,在其應用程式在包含該版本的 .NET Framework 上執行時,選擇新功能功能.For apps that call APIs in the .NET Framework, the <AppContextSwitchOverrides> element can also allow callers whose apps target an earlier version of the .NET Framework to opt into new functionality if their app is running on a version of the .NET Framework that includes that functionality.

<AppContextSwitchOverrides> 元素的 value 屬性是由單一字串組成,其中包含一或多個以分號分隔的名稱/值配對。The value attribute of the <AppContextSwitchOverrides> element consists of a single string that consists of one or more semicolon-delimited name/value pairs. 每個名稱都會識別相容性參數,而其對應的值是布林(truefalse),指出是否已設定參數。Each name identifies a compatibility switch, and its corresponding value is a Boolean (true or false) that indicates whether the switch is set. 根據預設,參數會 false,而程式庫會提供新的功能。By default, the switch is false, and libraries provide the new functionality. 它們只會在設定參數時提供先前的功能(亦即,其值為 true)。They only provide the previous functionality if the switch is set (that is, its value is true). 這可讓程式庫提供現有 API 的新行為,同時允許相依于先前行為的呼叫端選擇不使用新的功能。This allows libraries to provide new behavior for an existing API while allowing callers who depend on the previous behavior to opt out of the new functionality.

.NET Framework 支援下列參數:The .NET Framework supports the following switches:

交換器名稱Switch name 描述Description 引導Introduced
Switch.MS.Internal.
DoNotApplyLayoutRoundingToMarginsAndBorderThickness
控制 Windows Presentation Foundation 是否使用舊版的控制項配置演算法。Controls whether Windows Presentation Foundation uses legacy a algorithm for control layout. 如需詳細資訊,請參閱風險降低:WPF 版面配置For more information, see Mitigation: WPF Layout. .NET Framework 4.6.NET Framework 4.6
Switch.MS.Internal.
UseSha1AsDefaultHashAlgorithmForDigitalSignatures
控制用於 PackageDigitalSignatureManager 封裝元件的預設演算法是否為 SHA1 或 SHA256。Controls whether the default algorithm used for signing parts of a package by PackageDigitalSignatureManager is SHA1 or SHA256.
由於 SHA1 的衝突問題,Microsoft 建議使用 SHA256。Due to collision problems with SHA1, Microsoft recommends SHA256.
.NET Framework 4.7.1.NET Framework 4.7.1
Switch.System.Activities.
UseMD5CryptoServiceProviderForWFDebugger
設定為 false時,允許在啟用 FIPS 時,使用 Visual Studio 來進行 XAML 型工作流程專案的調試。When set to false, allows debugging of XAML-based workflow projects with Visual Studio when FIPS is enabled. 若沒有此功能,就會在對 System.object 元件中的方法呼叫中擲回 NullReferenceExceptionWithout it, a NullReferenceException is thrown in calls to methods in the System.Activities assembly. .NET Framework 4.7.NET Framework 4.7
Switch.System.Activities.
UseMD5ForWFDebugger
控制偵錯工具中的工作流程實例總和檢查碼是否使用 MD5 或 SHA1。Controls whether the checksum for a workflow instance in the debugger uses MD5 or SHA1. .NET Framework 4.7.NET Framework 4.7
Switch.System.Activities.
UseSHA1HashForDebuggerSymbols
控制工作流程總和檢查碼雜湊是否使用在 .NET Framework 4.7 (true)中引進為預設值的 SHA1 演算法,或是否使用在 .NET Framework 4.8 (false)中導入為預設值的預設 SHA256 演算法。Controls whether workflow checksum hashing uses the SHA1 algorithm introduced as the default in .NET Framework 4.7 (true), or whether it uses the default SHA256 algorithm introduced as the default in .NET Framework 4.8 (false).
由於 SHA1 的衝突問題,Microsoft 建議使用 SHA256。Due to collision problems with SHA1, Microsoft recommends SHA256.
.NET Framework 4.8.NET Framework 4.8
Switch.System.Diagnostics.
IgnorePortablePDBsInStackTraces
控制使用可移植 Pdb 時是否取得堆疊追蹤,可以包含原始程式檔和行資訊。Controls whether stack traces obtain when using portable PDBs can include source file and line information. false 包含原始程式檔和行資訊;否則,truefalse to include source file and line information; otherwise, true. .NET Framework 4.7.2.NET Framework 4.7.2
Switch.System.Drawing.
DontSupportPngFramesInIcons
控制當 Icon 物件具有 PNG 畫面格時,Icon.ToBitmap 方法是否擲回例外狀況。Controls whether the Icon.ToBitmap method throws an exception when an Icon object has PNG frames. 如需詳細資訊,請參閱風險降低:Icon 物件中的 PNG 畫面格For more information, see Mitigation: PNG Frames in Icon Objects. .NET Framework 4.6.NET Framework 4.6
Switch.System.Drawing.Text.
DoNotRemoveGdiFontsResourcesFromFontCollection
判斷當 PrivateFontCollection.AddFontFile(String) 方法新增至集合時,是否正確處置 System.Drawing.Text.PrivateFontCollection 物件。Determines whether System.Drawing.Text.PrivateFontCollection objects are properly disposed when added to the collection by the PrivateFontCollection.AddFontFile(String) method. true 維護舊版行為;false 所有私用字型物件的處置。true to maintain the legacy behavior; false to dispose of all private font objects. .NET Framework 4.7.2.NET Framework 4.7.2
Switch.System.Drawing.Printing.
OptimizePrintPreview
控制 PrintPreviewDialog 的效能是否已針對網路印表機優化。Controls whether the performance of the PrintPreviewDialog is optimized for network printers. 如需詳細資訊,請參閱PrintPreviewDialog 控制項總覽For more information, see PrintPreviewDialog control overview. .NET Framework 4.6.NET Framework 4.6
Switch.System.Globalization.EnforceJapaneseEraYearRanges 控制是否強制執行日文日曆紀元的年份範圍檢查。Controls whether year range checks for Japanese calendar eras are enforced. true 強制執行年份範圍檢查,並 false 停用它們(預設行為)。true to enforce year range checks, and false to disable them (the default behavior). 如需詳細資訊,請參閱使用行事曆For more information, see Working with calendars. .NET Framework 4.6.NET Framework 4.6
Switch.System.Globalization.EnforceLegacyJapaneseDateParsing 控制是否只在剖析作業中,將 "1" 辨識為日本日曆紀元的第一年。Controls whether only "1" is recognized as the first year of a Japanese calendar era in parsing operations. true 只能辨識 "1";false 辨識 "1" 或 Gannen (預設行為)。true to recognize only "1"; false to recognize either "1" or Gannen (the default behavior). 如需詳細資訊,請參閱使用行事曆For more information, see Working with calendars. .NET Framework 4.6.NET Framework 4.6
Switch.System.Globalization.FormatJapaneseFirstYearAsANumber 控制日本日曆紀元的第一年是否在格式化作業中表示為 "1" 或 Gannen。Controls whether the first year of a Japanese calendar era is represented as "1" or Gannen in formatting operations. true 將紀元的第一年格式化為 "1";false 將其格式化為 Gannen (預設行為)。true to format the era's first year as "1"; false to format it as Gannen (the default behavior). 如需詳細資訊,請參閱使用行事曆For more information, see Working with calendars. .NET Framework 4.6.NET Framework 4.6
Switch.System.Globalization.NoAsyncCurrentCulture 控制非同步作業是否不會從呼叫執行緒的內容流動。Controls whether asynchronous operations do not flow from the calling thread's context. 如需詳細資訊,請參閱跨工作的CurrentCulture 和 CurrentUICulture 流程For more information, see CurrentCulture and CurrentUICulture flow across tasks. .NET Framework 4.6.NET Framework 4.6
Switch.System.IdentityModel.
DisableMultipleDNSEntriesInSANCertificate
控制 X509CertificateClaimSet.FindClaims 方法是否只嘗試比對宣告類型與最後一個 DNS 專案。Controls whether the X509CertificateClaimSet.FindClaims method attempts to match the claim type only with the last DNS entry. 如需詳細資訊,請參閱風險降低:X509CertificateClaimSet.FindClaims 方法For more information, see Mitigation: X509CertificateClaimSet.FindClaims Method. .NET Framework 4.6.1.NET Framework 4.6.1
Switch.System.IdentityModel.
EnableCachedEmptyDefaultAuthorizationContext
控制是否允許 AuthorizationCoNtext 傳回可變物件。Controls whether to allow AuthorizationContext.Empty to return a mutable object. .NET Framework 4.6.NET Framework 4.6
Switch.System.IO.BlockLongPaths 控制路徑長度超過 MAX_PATH (260個字元)是否擲回 PathTooLongExceptionControls whether paths longer than MAX_PATH (260 characters) throw a PathTooLongException. 如需詳細資訊,請參閱長路徑支援For more information, see Long Path Support. .NET Framework 4.6.2.NET Framework 4.6.2
Switch.System.IO.Compression.
DoNotUseNativeZipLibraryForDecompression
控制 DeflateStream 類別是否使用原生 OS 常式進行解壓縮。Controls whether native OS routines are used for decompression by the DeflateStream class. false 使用原生 Api;true 使用 DeflateStream 的執行方式。false to use native APIs; true to use the DeflateStream implementation. .NET Framework 4.7.2.NET Framework 4.7.2
Switch.System.IO.Compression.ZipFile.
UseBackslash
使用反斜線("\"),而不是正斜線("/")做為 ZipArchiveEntry.FullName 屬性中的路徑分隔符號。Uses the backslash ("\") rather than the forward slash ("/") as the path separator in the ZipArchiveEntry.FullName property. 如需詳細資訊,請參閱風險降低: ziparchiveentry 中. FullName 路徑分隔符號For more information, see Mitigation: ZipArchiveEntry.FullName Path Separator. .NET Framework 4.6.1.NET Framework 4.6.1
Switch.System.IO.Ports.
DoNotCatchSerialStreamThreadExceptions
控制在以 SerialPort 資料流程建立的背景執行緒上擲回的作業系統例外狀況是否終止進程。Controls whether operating system exceptions that are thrown on background threads created with SerialPort streams terminate the process. .NET Framework 4.7.1.NET Framework 4.7.1
Switch.System.IO.
UseLegacyPathHandling
控制是否使用舊版路徑正規化,以及 Path.GetDirectoryNamePath.GetPathRoot 方法是否支援 URI 路徑。Controls whether legacy path normalization is used and URI paths are supported by the Path.GetDirectoryName and Path.GetPathRoot methods. 如需詳細資訊,請參閱風險降低:路徑正規化和緩和:路徑冒號檢查For more information, see Mitigation: Path Normalization and Mitigation: Path Colon Checks. .NET Framework 4.6.2.NET Framework 4.6.2
Switch.System.
MemberDescriptorEqualsReturnsFalseIfEquivalent
控制是否相等的測試會比較一個物件的 MemberDescriptor.Category 屬性與第二個物件的 MemberDescriptor.Description 屬性。Controls whether a test for equality compares the MemberDescriptor.Category property of one object with the MemberDescriptor.Description property of the second object. 如需詳細資訊,請參閱System.componentmodel.memberdescriptor.equals 不正確的執行For more information, see Incorrect implementation of MemberDescriptor.Equals. .NET Framework 4.6.2.NET Framework 4.6.2
Switch.System.Net.
DontCheckCertificateEKUs
停用憑證增強金鑰使用方法(EKU)物件識別碼(OID)驗證。Disables certificate enhanced key usage (EKU) object identifier (OID) validation. 增強金鑰使用方法 (EKU) 延伸模組是表示使用金鑰之應用程式的物件識別碼 (OID) 集合。An enhanced key usage (EKU) extension is a collection of object identifiers (OIDs) that indicate the applications that use the key. .NET Framework 4.6.NET Framework 4.6
Switch.System.Net.
DontEnableSchSendAuxRecord
停用 SCH_SEND_AUX_RECORD,藉此停用 TLS 1.0 瀏覽器,以避免 SSL/TLS (BEAST)緩和。Disables TLS1.0 Browser Exploit Against SSL/TLS (BEAST) mitigation by disabling the use of SCH_SEND_AUX_RECORD. .NET Framework 4.6.NET Framework 4.6
Switch.System.Net.
DontEnableSchUseStrongCrypto
控制 System.Net.ServicePointManagerSystem.Net.Security.SslStream 類別是否可以使用 SSL 3.0 通訊協定。Controls whether the System.Net.ServicePointManager and System.Net.Security.SslStream classes can use the SSL 3.0 protocol. 如需詳細資訊,請參閱風險降低:TLS 通訊協定For more information, see Mitigation: TLS Protocols. .NET Framework 4.6.NET Framework 4.6
Switch.System.Net.
DontEnableSystemDefaultTlsVersions
停用 SystemDefault 的 TLS 版本還原為預設的 Tls12、Tls11、Tls。Disables SystemDefault TLS versions reverting back to a default of Tls12, Tls11, Tls. .NET Framework 4.7.NET Framework 4.7
Switch.System.Net.
DontEnableTlsAlerts
停用 SslStream TLS 伺服器端警示。Disables SslStream TLS server-side Alerts. .NET Framework 4.7.NET Framework 4.7
Switch.System.Runtime.InteropServices.
DoNotMarshalOutByrefSafeArrayOnInvoke
控制 COM Interop 事件上的 ByRef SafeArray 參數是否會封送處理回機器碼(false),或是否已停用送回機器碼的(true)。Controls whether ByRef SafeArray parameters on COM interop events marshal back to native code (false) or whether marshaling back to native code is disabled (true). .NET Framework 4.8.NET Framework 4.8
Switch.System.Runtime.Serialization.
DoNotUseECMAScriptV6EscapeControlCharacter
控制DataContractJsonSerializer是否會根據 ECMAScript V6 和 V8 標準序列化某些控制字元。Controls whether the DataContractJsonSerializer serializes some control characters based on the ECMAScript V6 and V8 standards. 如需詳細資訊,請參閱風險降低︰使用 DataContractJsonSerializer 控制字元的序列化For more information, see Mitigation: Serialization of Control Characters with the DataContractJsonSerializer .NET Framework 4.7.NET Framework 4.7
Switch.System.Runtime.Serialization.
DoNotUseTimeZoneInfo
控制 DataContractJsonSerializer 是否支援多個調整,或僅針對某個時區進行單一調整。Controls whether the DataContractJsonSerializer supports multiple adjustments or only a single adjustment for a time zone. 如果 true,它會使用 TimeZoneInfo 類型來序列化和還原序列化日期和時間資料;否則,它會使用不支援多個調整規則的 TimeZone 類型。If true, it uses the TimeZoneInfo type to serialize and deserialize date and time data; otherwise, it uses the TimeZone type, which does not support multiple adjustment rules. .NET Framework 4.6.2.NET Framework 4.6.2
Switch.System.Runtime.Serialization.UseNewMaxArraySize 控制在物件序列化和還原序列化期間,System.Runtime.Serialization.ObjectManager 是否使用較大的陣列大小。Controls whether System.Runtime.Serialization.ObjectManager uses a larger array size during object serialization and deserialization. 將此參數設定為 true,藉由 BinaryFormatter之類的類型來改善大型物件圖形的序列化和還原序列化效能。Set this switch to true to improve the performance of serialization and deserialization of large object graphs by types such as BinaryFormatter. .NET Framework 4.7.2.NET Framework 4.7.2
Switch.System.Security.ClaimsIdentity.
SetActorAsReferenceWhenCopyingClaimsIdentity
控制 ClaimsIdentity.ClaimsIdentity(IIdentity) 的函式是否使用現有的物件參考來設定新物件的 ClaimsIdentity.Actor 屬性。Controls whether the ClaimsIdentity.ClaimsIdentity(IIdentity) constructor sets the new object's ClaimsIdentity.Actor property with an existing object reference. 如需詳細資訊,請參閱風險降低︰ClaimsIdentity 建構函式For more information, see Mitigation: ClaimsIdentity Constructor. .NET Framework 4.6.2.NET Framework 4.6.2
Switch.System.Security.Cryptography.
AesCryptoServiceProvider.DontCorrectlyResetDecryptor
控制嘗試重複使用 AesCryptoServiceProvider 解密子是否會擲回 CryptographicExceptionControls whether the attempt to reuse an AesCryptoServiceProvider decryptor throws a CryptographicException. 如需詳細資訊,請參閱AesCryptoServiceProvider 解密程式提供可重複使用的轉換For more information, see AesCryptoServiceProvider decryptor provides a reusable transform. .NET Framework 4.6.2.NET Framework 4.6.2
Switch.System.Security.Cryptography.
DoNotAddrOfCspParentWindowHandle
控制CspParameters. system.security.cryptography.cspparameters.parentwindowhandle屬性的值是否為代表視窗控制碼之記憶體位置的IntPtr ,或其是否為視窗控制碼(HWND)。Controls whether the value of the CspParameters.ParentWindowHandle property is an IntPtr that represents the memory location of a window handle, or whether it is a window handle (an HWND). 如需詳細資訊,請參閱風險降低︰CspParameters.ParentWindowHandle 應該有 HWNDFor more information, see Mitigation: CspParameters.ParentWindowHandle Expects an HWND. .NET Framework 4.7.NET Framework 4.7
Switch.System.Security.Cryptography.
UseLegacyFipsThrow
控制在 FIPS 模式中使用受管理的加密類別是否會擲回 CryptographicExceptiontrue),或依賴系統程式庫(false)的執行。Controls whether the use of managed cryptography classes in FIPS mode throws a CryptographicException (true) or relies on the implementation of system libraries (false). .NET Framework 4.8.NET Framework 4.8
Switch.System.Security.Cryptography.Pkcs.
UseInsecureHashAlgorithms
判斷某些 SignedCMS 作業的預設值為 SHA1 或 SHA256。Determines whether the default for some SignedCMS operations is SHA1 or SHA256.
由於 SHA1 的衝突問題,Microsoft 建議使用 SHA256。Due to collision problems with SHA1, Microsoft recommends SHA256.
.NET Framework 4.7.1.NET Framework 4.7.1
Switch.System.Security.Cryptography.X509Certificates.
ECDsaCertificateExtensions.UseLegacyPublicKeyReader
控制 ECDsaCertificateExtensions.GetECDsaPublicKey 方法是否正確地處理作業系統(false)支援的所有命名曲線,或還原成舊版行為。Controls whether the ECDsaCertificateExtensions.GetECDsaPublicKey method correctly handles all named curves supported by the operating system (false) or reverts to legacy behavior. .NET Framework 4.8.NET Framework 4.8
Switch.System.Security.Cryptography.Xml.
UseInsecureHashAlgorithms
判斷某些 SignedXML 作業的預設值為 SHA1 或 SHA256。Determines whether the default for some SignedXML operations is SHA1 or SHA256.
由於 SHA1 的衝突問題,Microsoft 建議使用 SHA256。Due to collision problems with SHA1, Microsoft recommends SHA256.
.NET Framework 4.7.1.NET Framework 4.7.1
Switch.System.ServiceModel.
AllowUnsignedToHeader
判斷 TransportWithMessageCredential 安全性模式是否允許具有不帶正負號 "to" 標頭的訊息。Determines whether the TransportWithMessageCredential security mode allows messages with an unsigned "to" header. 這是選擇性參數。This is an opt-in switch. 如需詳細資訊,請參閱.NET Framework 4.6.1 中的執行時間變更For more information, see Runtime Changes in the .NET Framework 4.6.1. .NET Framework 4.6.1.NET Framework 4.6.1
Switch.System.ServiceModel.
DisableAddressHeaderCollectionValidation>
控制如果 null其中一個元素,AddressHeaderCollection(IEnumerable<AddressHeader>) 的函式是否會擲回 ArgumentExceptionControls whether the AddressHeaderCollection(IEnumerable<AddressHeader>) constructor throws an ArgumentException if one of the elements is null. .NET Framework 4.7.1.NET Framework 4.7.1
Switch.System.ServiceModel.
DisableCngCertificates
判斷嘗試搭配 CSG 金鑰儲存提供者使用 X509 憑證是否擲回例外狀況。Determines whether the attempt to use X509 certificates with a CSG key storage provider throws an exception. 如需詳細資訊,請參閱WCF 傳輸安全性支援使用 CNG 儲存的憑證For more information, see WCF transport security supports certificates stored using CNG. .NET Framework 4.6.1.NET Framework 4.6.1
Switch.System.ServiceModel.
DisableExplicitConnectionCloseHeader
搭配自我裝載服務使用 HTTP 傳輸時,將此值設定為 true 會導致 WCF 忽略應用程式將 Connection: close 標頭加入至要求的回應標頭。When using the HTTP transport with a self-hosted service, setting this value to true causes WCF to ignore an application adding the Connection: close header to the response headers for a request. 將此值設定為 false 可將 Connection: close 標頭新增至回應標頭,這會導致在傳送回應之後關閉要求通訊端。Setting this value to false enables adding the Connection: close header to the response headers, which results in closing the request socket after a response has been sent. .NET Framework 4.6.NET Framework 4.6
Switch.System.ServiceModel.
DisableOperationContextAsyncFlow
處理因為將可重新進入服務的實例限制為一次執行單一執行緒而產生的鎖死。Handles deadlocks that result from restricting instances of a reentrant service to a single thread of execution at a time. .NET Framework 4.6.2.NET Framework 4.6.2
Switch.System.ServiceModel.
DisableUsingServicePointManagerSecurityProtocols
除了 Switch.System.Net.DontEnableSchUseStrongCrypto,判斷 WCF 訊息安全性是否使用 TLS 1.1 和 TLS 1.2。Along with Switch.System.Net.DontEnableSchUseStrongCrypto, determines whether WCF message security uses TLS 1.1 and TLS 1.2. .NET Framework 4.7.NET Framework 4.7
Switch.System.ServiceModel.
DontEnableSystemDefaultTlsVersions
false 會將預設設定設為允許作業系統選擇通訊協定。A value of false sets the default configuration to allow the operating system to choose the protocol. true 會將預設值設定為可用的最高通訊協定。A value of true sets the default to the highest protocol available. (也適用于舊版架構的服務分支)(Also available on servicing branch of previous framework versions) .NET Framework 4.7.1.NET Framework 4.7.1
Switch.System.ServiceModel.
UseSha1InMsmqEncryptionAlgorithm
判斷 WCF 中 MSMQ 訊息的預設訊息簽署演算法是 SHA1 或 SHA256。Determines whether the default message signing algorithm for MSMQ messages in WCF is SHA1 or SHA256.
由於 SHA1 的衝突問題,Microsoft 建議使用 SHA256。Due to collision problems with SHA1, Microsoft recommends SHA256.
.NET Framework 4.7.1.NET Framework 4.7.1
Switch.System.ServiceModel.
UseSha1InPipeConnectionGetHashAlgorithm
控制 WCF 是否使用 SHA1 或 SHA256 雜湊來產生具名管道的隨機名稱。Controls whether WCF uses a SHA1 or a SHA256 hash to generate random names for named pipes.
由於 SHA1 的衝突問題,Microsoft 建議使用 SHA256。Due to collision problems with SHA1, Microsoft recommends SHA256.
.NET Framework 4.7.1.NET Framework 4.7.1
Switch.System.ServiceModel.Internals
IncludeNullExceptionMessageInETWTrace
控制是否要在例外狀況訊息為 null 時擲回NullReferenceExceptionControls whether to throw a NullReferenceException when the exception message is null. .NET Framework 4.7.NET Framework 4.7
Switch.System.ServiceProcess.
DontThrowExceptionsOnStart
控制在服務啟動時擲回的例外狀況是否會傳播到 ServiceBase.Run 方法的呼叫端。Controls whether exceptions thrown on service startup are propagated to the caller of the ServiceBase.Run method. .NET Framework 4.7.1.NET Framework 4.7.1
Switch.System.Threading.UseNetCoreTimer 控制 Timer 實例是否會利用高規模環境的效能改進。Controls whether Timer instances take advantage of performance improvements for high-scale environments. 如果 true,則會啟用效能改善;如果 false (預設值),則會停用。If true, the performance improvements are enabled; if false (the default value), they are disabled. .NET Framework 4.8.NET Framework 4.8
Switch.System.Uri.
DontEnableStrictRFC3986ReservedCharacterSets
判斷有時已解碼的特定百分比編碼字元,現在是否一致地保持編碼。Determines whether certain percent-encoded characters that were sometimes decoded are now consistently left encoded. 如果 true,則會將它們解碼;否則,falseIf true, they are decoded; otherwise, false. .NET Framework 4.7.2.NET Framework 4.7.2
Switch.System.Uri.
DontKeepUnicodeBidiFormattingCharacters
決定 Uri 中 Unicode 雙向字元的處理方式。Determines the handling of Unicode bidirectional characters in URIs. true 從 Uri 中去除它們;false 保留並對其進行百分比編碼。true to strip them from URIs; false to preserve and percent-encode them. .NET Framework 4.7.2.NET Framework 4.7.2
Switch.System.Windows.Controls.Grid.
StarDefinitionsCanExceedAvailableSpace
判斷 Windows Presentation Foundation 是否在配置空間給 *資料行時,套用舊的演算法(true)或新的演算法(false)。Determines whether Windows Presentation Foundation applies an old algorithm (true) or a new algorithm (false) in allocating space to *-columns. 如需詳細資訊,請參閱風險降低︰方格控制項對 Star-columns 的空間配置For more information, see Mitigation: Grid Control's Space Allocation to Star-columns. .NET Framework 4.7.NET Framework 4.7
Switch.System.Windows.Controls.TabControl.
SelectionPropertiesCanLagBehindSelectionChangedEvent
控制選取器或索引標籤控制項是否一律會在引發選取範圍變更事件之前更新其選取值屬性的值。Controls whether a selector or a tab control always updates the value of its selected value property before raising the selection changed event. .NET Framework 4.7.1.NET Framework 4.7.1
Switch.System.Windows.Controls.Text.
UseAdornerForTextboxSelectionRendering
決定 TextBoxPasswordBox 控制項是否可以使用非以裝飾項為基礎的選取轉譯,以防止 pixels occluded 文字(false),或文字是否只在裝飾項層(true)中轉譯。Determines whether non-Adorner based selection rendering is available for the TextBox and PasswordBox controls to prevent occluded text (false), or whether text is rendered only in the Adorner layer (true). .NET Framework 4.7.2.NET Framework 4.7.2
Switch.System.Windows.Data.Binding.
IListIndexerHidesCustomIndexer
控制 System.Windows.Data.Binding 類別是否不正確地使用自訂 IList 索引子(false)或正確(true)。Controls whether custom IList indexers are used incorrectly (false) or correctly (true) by the System.Windows.Data.Binding class. .NET Framework 4.8.NET Framework 4.8
Switch.System.Windows.DoNotScaleForDpiChanges 決定是否要在每個系統(false的值)或每個監視器(true的值)上發生 DPI 變更。Determines whether DPI changes occur on a per-system (a value of false) or per-monitor basis (a value of true). .NET Framework 4.6.2.NET Framework 4.6.2
Switch.System.Windows.
DoNotUsePresentationDpiCapabilityTier2OrGreater
控制當 WPF 在每個監視器感知模式下執行時,是否已改善 System.Windows.Interop.HwndHost 控制項的大小調整(true)或啟用(false)。Controls whether improvements in sizing of controls in a System.Windows.Interop.HwndHost when WPF is run in per-monitor aware mode are disabled (true) or enabled (false). .NET Framework 4.8.NET Framework 4.8
Switch.System.Windows.Forms.
DomainUpDown.UseLegacyScrolling
決定當有控制項文字時,開發人員是否需要特別處理 DomainUpDown.UpButton() 動作。Determines whether the developer needs to specially handle the DomainUpDown.UpButton() action when control text is present. true 來處理 UpButton() 動作;false DomainUpDown.UpButton()DomainUpDown.DownButton() 動作正確地同步。true to handle the UpButton() action; false for the DomainUpDown.UpButton() and DomainUpDown.DownButton() actions to be properly in sync. .NET Framework 4.7.2.NET Framework 4.7.2
Switch.System.Windows.Forms.
DontSupportReentrantFilterMessage
退出宣告程式碼,可讓自訂 IMessageFilter.PreFilterMessage 的執行安全地篩選訊息,而不會在呼叫 Application.FilterMessage 方法時擲回例外狀況。Opts out of the code that allows a custom IMessageFilter.PreFilterMessage implementation to safely filter messages without throwing an exception when the Application.FilterMessage method is called. 如需詳細資訊,請參閱風險降低:自訂 IMessageFilter.PreFilterMessage 實作For more information, see Mitigation: Custom IMessageFilter.PreFilterMessage Implementations. .NET Framework 4.6.1.NET Framework 4.6.1
Switch.System.Windows.Forms.
UseLegacyContextMenuStripSourceControlValue
判斷當使用者從嵌套 ToolStripMenuItem 控制項開啟功能表時,ContextMenuStrip.SourceControl 屬性是否會傳回原始檔控制。Determines whether the ContextMenuStrip.SourceControl property returns the source control when the user opens the menu from a nested ToolStripMenuItem control. true 傳回 null,這是舊版的行為;false 傳回原始檔控制。true to return null, the legacy behavior; false to return the source control. .NET Framework 4.7.2.NET Framework 4.7.2
Switch.System.Windows.Forms.UseLegacyToolTipDisplay 控制工具提示調用支援是否已停用(true)或啟用(false)。Controls whether tooltip invocation support is disabled (true) or enabled (false). 啟用工具提示調用支援也需要由 Switch.UseLegacyAccessibilityFeaturesSwitch.UseLegacyAccessibilityFeatures.2Switch.UseLegacyAccessibilityFeatures.3 所定義的舊版存取範圍功能,而全部都是停用的(設定為 false)。Enabling tooltip invocation support also requires legacy accessibility features defined by Switch.UseLegacyAccessibilityFeatures, Switch.UseLegacyAccessibilityFeatures.2, and Switch.UseLegacyAccessibilityFeatures.3 all be disabled (set to false). .NET Framework 4.8.NET Framework 4.8
Switch.System.Windows.Input.Stylus.
EnablePointerSupport
決定是否在 WPF 應用程式中啟用選擇性的以 WM_POINTER為基礎的觸控/手寫筆堆疊。Determines whether an optional WM_POINTER-based touch/stylus stack is enabled in WPF applications. 如需詳細資訊,請參閱緩和:以指標為基礎的觸控和手寫筆支援For more information, see Mitigation: Pointer-based Touch and Stylus Support .NET Framework 4.7.NET Framework 4.7
Switch.System.Windows.Markup.
DoNotUseSha256ForMarkupCompilerChecksumAlgorithm
判斷用於總和檢查碼的預設雜湊演算法是 SHA256 (false)或 SHA1 (true)。Determines whether the default hash algorithm used for checksums is SHA256 (false) or SHA1 (true).
由於 SHA1 的衝突問題,Microsoft 建議使用 SHA256。Due to collision problems with SHA1, Microsoft recommends SHA256.
.NET Framework 4.7.2.NET Framework 4.7.2
Switch.System.Windows.Media.ImageSourceConverter.
OverrideExceptionWithNullReferenceException
控制是否擲回舊版NullReferenceException ,而不是例外狀況,更明確地指出例外狀況的原因(例如DirectoryNotFoundExceptionFileNotFoundException)。Controls whether a legacy NullReferenceException is thrown instead of the exception that more specifically indicates the cause of the exception (such as a DirectoryNotFoundException or a FileNotFoundException. 其目的是要讓相依于處理NullReferenceException的程式碼使用。It is intended for use by code that depends on handling the NullReferenceException. .NET Framework 4.7.NET Framework 4.7
Switch.System.Workflow.ComponentModel.
UseLegacyHashForXomlFileChecksum
控制工作流程專案組建中 XOML 檔的總和檢查碼雜湊是否使用 MD5 演算法(true),或是否使用 .NET Framework 4.8 中導入為預設值的 SHA256 演算法。Controls whether checksum hashing of XOML files in workflow project builds use the MD5 algorithm (true), or whether they use the SHA256 algorithm introduced as the default in .NET Framework 4.8.
由於 MD5 的衝突問題,Microsoft 建議使用 SHA256。Due to collision problems with MD5, Microsoft recommends SHA256.
.NET Framework 4.8.NET Framework 4.8
Switch.System.Workflow.Runtime.
UseLegacyHashForSqlTrackingCacheKey
控制 SqlTrackingService 的總和檢查碼雜湊是否針對快取的字串使用 MD5 演算法(true),或是否使用 .NET Framework 4.8 中引進為預設值的 SHA256 演算法。Controls whether checksum hashing by the SqlTrackingService uses the MD5 algorithm (true) for cached strings, or whether it uses the SHA256 algorithm introduced as the default in .NET Framework 4.8.
由於 MD5 的衝突問題,Microsoft 建議使用 SHA256。Due to collision problems with MD5, Microsoft recommends SHA256.
.NET Framework 4.8.NET Framework 4.8
Switch.System.Workflow.Runtime.
UseLegacyHashForWorkflowDefinitionDispenserCacheKey
控制工作流程執行時間的總和檢查碼雜湊是否針對快取的工作流程定義使用 MD5 演算法(true),或是否使用 .NET Framework 4.8 中導入為預設值的 SHA256 演算法。Controls whether checksum hashing by the Workflow Runtime uses the MD5 algorithm (true) for cached workflow definitions, or whether it uses the SHA256 algorithm introduced as the default in .NET Framework 4.8.
由於 MD5 的衝突問題,Microsoft 建議使用 SHA256。Due to collision problems with MD5, Microsoft recommends SHA256.
.NET Framework 4.8.NET Framework 4.8
Switch.UseLegacyAccessibilityFeatures 控制是否啟用或停用從 .NET Framework 4.7.1 開始提供的協助工具功能。Controls whether accessibility features available starting with .NET Framework 4.7.1 are enabled or disabled. .NET Framework 4.7.1.NET Framework 4.7.1
Switch.UseLegacyAccessibilityFeatures.2 控制是否啟用 .NET Framework 4.7.2 中可用的協助工具功能(false)或停用(true)。Controls whether accessibility features available in .NET Framework 4.7.2 are enabled (false) or disabled (true). 如果 true,也必須 true Switch.UseLegacyAccessibilityFeatures,才能啟用 .NET Framework 4.7.1 協助工具功能。If true, Switch.UseLegacyAccessibilityFeatures must also be true to enable .NET Framework 4.7.1 accessibility features. .NET Framework 4.7.2.NET Framework 4.7.2
Switch.UseLegacyAccessibilityFeatures.3 控制是否啟用(false)或停用(true) .NET Framework 4.8 中引進的協助工具功能。Controls whether accessibility features introduced in .NET Framework 4.8 are enabled (false) or disabled (true). 如果 trueSwitch.UseLegacyAccessibilityFeaturesSwitch.UseLegacyAccessibilityFeatures.2 也必須 trueIf true, Switch.UseLegacyAccessibilityFeatures and Switch.UseLegacyAccessibilityFeatures.2 must also be true. .NET Framework 4.8.NET Framework 4.8
Switch.UseLegacyToolTipDisplay 控制當使用者將滑鼠游標停留在 WPF 控制項上時,是否顯示工具提示(true),或是否要在鍵盤焦點和透過鍵盤快速鍵(false,預設行為)顯示。Controls whether tooltips are displayed when a user hovers the mouse cursor over a WPF control (true), or whether they are displayed both on keyboard focus and via keyboard shortcut key (false, the default behavior). 對於在 .NET Framework 4.8 上執行但以舊版 .NET Framework 為目標的應用程式,同時啟用鍵盤焦點和快速鍵支援時,必須將 Switch.UseLegacyAccessibilityFeaturesSwitch.UseLegacyAccessibilityFeatures.2Switch.UseLegacyAccessibilityFeatures.3 全部設定為 falseFor applications running on .NET Framework 4.8 but targeting previous versions of the .NET Framework, enabling both keyboard focus and shortcut key support requires that Switch.UseLegacyAccessibilityFeatures, Switch.UseLegacyAccessibilityFeatures.2, and Switch.UseLegacyAccessibilityFeatures.3 all be set to false. .NET Framework 4.8.NET Framework 4.8
System.Xml.

IgnoreEmptyKeySequences
控制 XSD 架構驗證是否忽略複合索引鍵中的空白索引鍵序列。Controls whether empty key sequences in compound keys are ignored by XSD schema validation. 如需詳細資訊,請參閱風險降低: XML 架構驗證For more information, see Mitigation: XML Schema Validation. .NET Framework 4.6.NET Framework 4.6

注意

您也可以藉由呼叫 static (在中C#)或 Shared (Visual Basic) AppContext.SetSwitch 方法,以程式設計方式設定參數,而不是將 AppContextSwitchOverrides 專案新增至應用程式佈建檔。Instead of adding an AppContextSwitchOverrides element to an application configuration file, you can also set the switches programmatically by calling the static (in C#) or Shared (in Visual Basic) AppContext.SetSwitch method.

程式庫開發人員也可以定義自訂參數,以允許呼叫者選擇不要在較新版本的程式庫中引進變更的功能。Library developers can also define custom switches to allow callers to opt out of changed functionality introduced in later versions of their libraries. 如需詳細資訊,請參閱 AppContext 類別。For more information, see the AppContext class.

ASP.NET 應用程式中的參數Switches in ASP.NET applications

您可以將 ASP.NET 應用程式設定為使用相容性設定,方法是將<新增 >元素新增至 web.config 檔案的<appSettings >區段。You can configure an ASP.NET application to use compatibility settings by adding an <Add> element to the <appSettings> section of the web.config file.

下列範例會使用 <add> 元素,將兩個設定加入 web.config 檔案的 <appSettings> 區段中:The following example uses the <add> element to add two settings to the <appSettings> section of a web.config file:

<appSettings>
  <add key="AppContext.SetSwitch:Switch.System.Globalization.NoAsyncCurrentCulture" value="true" />
  <add key="AppContext.SetSwitch:Switch.System.Uri.DontEnableStrictRFC3986ReservedCharacterSets" value="true" />
</appSettings>

範例Example

下列範例會使用 AppContextSwitchOverrides 元素來定義單一應用程式相容性參數,Switch.System.Globalization.NoAsyncCurrentCulture,以防止文化特性在非同步方法呼叫中跨執行緒流動。The following example uses the AppContextSwitchOverrides element to define a single application compatibility switch, Switch.System.Globalization.NoAsyncCurrentCulture, that prevents culture from flowing across threads in asynchronous method calls.

<configuration>  
   <runtime>  
      <AppContextSwitchOverrides value="Switch.System.Globalization.NoAsyncCurrentCulture=true" />  
   </runtime>  
</configuration>  

下列範例會使用 AppContextSwitchOverrides 元素來定義兩個應用程式相容性參數,Switch.System.Globalization.NoAsyncCurrentCultureSwitch.System.IO.BlockLongPathsThe following example uses the AppContextSwitchOverrides element to define two application compatibility switches, Switch.System.Globalization.NoAsyncCurrentCulture and Switch.System.IO.BlockLongPaths. 請注意,分號會分隔兩個名稱/值組。Note that a semicolon separates the two name/value pairs.

<configuration>  
    <runtime>  
       <AppContextSwitchOverrides   
          value="Switch.System.Globalization.NoAsyncCurrentCulture=true;Switch.System.IO.BlockLongPaths=true" />  
    </runtime>  
</configuration>  

請參閱See also