<AppContextSwitchOverrides> 項目<AppContextSwitchOverrides> element

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

<configuration>
  <runtime>
    <AppContextSwitchOverrides>

SyntaxSyntax

<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 Attribute

Value 描述Description
"name = value""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 .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.

專案的 value 屬性 <AppContextSwitchOverrides> 包含單一字串,其中包含一個或多個以分號分隔的名稱/值組。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. 只有在參數設定 (也會) 其值時,才會提供先前的功能 trueThey 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 支援下列參數:.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. 如果沒有它, NullReferenceException 就會在呼叫 system.string 元件中的方法時擲回。Without 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 () 中引進的 SHA1 演算法 true ,或是否使用 .NET Framework 4.8 () 中引進的預設 SHA256 演算法 falseControls 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.ToBitmapIcon 物件具有 PNG 框架時,方法是否擲回例外狀況。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
判斷 System.Drawing.Text.PrivateFontCollection 當方法將物件加入至集合時,是否已適當處置物件 PrivateFontCollection.AddFontFile(String)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
控制類別是否使用原生 OS 常式進行解壓縮 DeflateStreamControls 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.FullNameUses 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
控制是否使用舊版路徑正規化,以及和方法是否支援 URI 路徑 Path.GetDirectoryName Path.GetPathRootControls 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
停用對 SSL/TLS 的 TLS 1.0 瀏覽器惡意探索 (怪獸透過停用 SCH_SEND_AUX_RECORD 來) 緩和措施。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.ServicePointManager 和類別是否 System.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) ,或是否已停用 () 的封送處理回原生程式碼 trueControls 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 可改善大型物件圖形序列化和還原序列化的效能(例如) BinaryFormatterSet 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(IIdentity) ClaimsIdentity.Actor 式是否以現有的物件參考來設定新物件的屬性。Controls whether the 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 模式中使用 managed 加密類別是否會擲回 CryptographicException (true) 或依賴 () 的系統程式庫執行 falseControls 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>
控制 AddressHeaderCollection(IEnumerable<AddressHeader>) ArgumentException 如果其中一個專案是,則此函式是否擲回 nullControls 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 re-entrant 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. (也可在舊版 framework 的服務分支上使用) (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.RunControls 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
決定是否可針對和控制項使用非以裝飾項為基礎的選取範圍轉譯 TextBox PasswordBox ,以防止 pixels occluded 文字 (false) ,或文字是否只在裝飾項層 () 中轉譯 trueDetermines 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
控制是否使用不正確的自訂 IList 索引子 (true) ,或 false 由類別正確 () System.Windows.Data.BindingControls whether custom IList indexers are used incorrectly (true) or correctly (false) by the System.Windows.Data.Binding class. .NET Framework 4.8.NET Framework 4.8
Switch.System.Windows.DoNotScaleForDpiChanges 決定是否要在每個系統上進行 DPI 變更, () 或個別監視器的值, false () 的值 trueDetermines 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.FilterMessageOpts 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
決定 ContextMenuStrip.SourceControl 當使用者從嵌套控制項開啟功能表時,屬性是否傳回原始檔控制 ToolStripMenuItemDetermines 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) 或啟用 () 的工具提示調用支援 falseControls whether tooltip invocation support is disabled (true) or enabled (false). 啟用工具提示調用支援也需要由、和定義的舊版協助工具功能, Switch.UseLegacyAccessibilityFeatures Switch.UseLegacyAccessibilityFeatures.2 Switch.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
決定是否 WM_POINTER 在 WPF 應用程式中啟用選擇性式觸控/手寫筆堆疊。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
控制工作流程執行時間的總和檢查碼雜湊是否使用 (true) 的 MD5 演算法來進行快取工作流程定義,或者是否使用在 .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 為,則 Switch.UseLegacyAccessibilityFeatures 也必須是, true 才能啟用 .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 控制是否啟用 .NET Framework 4.8 中引進的協助工具功能 (false) 或停用 (true) 。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.UseLegacyAccessibilityFeatures Switch.UseLegacyAccessibilityFeatures.2 將、和 Switch.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
Switch.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

注意

AppContextSwitchOverrides您也可以藉由呼叫 static c # ) 中的 (或 Shared Visual Basic) 方法中的 (,以程式設計方式設定參數,而不是將專案新增至應用程式佈建檔 AppContext.SetSwitchInstead 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 apps 中的交換器Switches in ASP.NET apps

您可以將專案新增 <Add> 至 web.config 檔案的區段,以將 ASP.NET 應用程式設定為使用相容性設定 <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. 分號會分隔兩個名稱/值配對。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