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

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. 如果此开关设置,它们会仅提供以前的功能 (也就是说,其值是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,允许基于 XAML 的工作流项目使用 Visual Studio 调试时启用了 FIPS。When set to false, allows debugging of XAML-based workflow projects with Visual Studio when FIPS is enabled. 如果没有它, NullReferenceException System.Activities 程序集中的方法调用引发。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
控制工作流校验和哈希是否使用 SHA1 算法引入.NET Framework 4.7 中的默认值为 (true),或者是否使用默认的 SHA256 算法引入.NET Framework 4.8 中的默认值为 (false)。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.ToBitmap方法将引发异常时Icon对象具有 PNG 帧。Controls whether the Icon.ToBitmap method throws an exception when an Icon object has PNG frames. 有关详细信息,请参阅缓解:图标对象中的 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"或元年 (默认行为)。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"或元年在格式设置操作。Controls whether the first year of a Japanese calendar era is represented as "1" or Gannen in formatting operations. true 若要设置为"1"; 时代的第一年的格式false以其格式设置为元年 (默认行为)。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.Empty 返回可变的对象。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 例程用于通过解压缩DeflateStream类。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
控制是否使用旧版路径规范化和 URI 路径受Path.GetDirectoryNamePath.GetPathRoot方法。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. 有关详细信息,请参阅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 使用禁用 TLS1.0 浏览器利用针对 SSL/TLS (怪兽) 缓解措施。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
禁用恢复为默认值为 Tls12、 Tls11、 Tls SystemDefault 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 互操作事件的 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以提高性能的序列化和反序列化大型对象类型的关系图如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.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.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 模式,则会引发CryptographicException(true) 或依赖于系统库的实现 (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
控件是否GetECDsaPublicKey方法可正确处理由操作系统支持的所有已命名的曲线 (false) 或恢复到旧行为。Controls whether the 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
确定是否尝试使用 X509 证书与 CSG 密钥存储提供程序引发异常。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. (也可在服务的以前的 framework 版本的分支)(Also available on servicing branch of previous framework versions) .NET Framework 4.7.1.NET Framework 4.7.1
Switch.System.ServiceModel.
UseSha1InMsmqEncryptionAlgorithm
确定默认消息签名的 MSMQ 消息 WCF 中的算法为 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
控制是否引发NullReferenceException异常消息为 null 时。Controls 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. 有关详细信息,请参阅缓解:网格控件的空间分配到星型列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控制来防止封闭的文本 (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
控制是否错误地使用自定义 IList 索引器 (false) 或正确 (true) 由Binding类。Controls whether custom IList indexers are used incorrectly (false) or correctly (true) by the Binding class. .NET Framework 4.8.NET Framework 4.8
Switch.System.Windows.DoNotScaleForDpiChanges 确定每个系统上是否发生 DPI 更改 (值为false) 或每个监视器基础 (值为true)。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
控件是否改进中的控件的大小调整System.Windows.Interop.HwndHostWPF 中每个监视器感知模式下的运行时已禁用 (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
确定是否ContextMenuStrip.SourceControl属性返回的源控件,当用户从嵌套打开菜单时ToolStripMenuItem控件。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.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引发而不是具体指示导致异常的异常 (如DirectoryNotFoundExceptionFileNotFoundExceptionControls 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. 它旨在用于通过代码取决于处理NullReferenceExceptionIt 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). 如果trueSwitch.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.UseLegacyAccessibilityFeaturesSwitch.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
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.SetSwitch方法。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 应用程序通过将添加使用兼容性设置<添加 >元素 <appSettings > web.config 文件部分。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>元素添加到两个设置<appSettings>web.config 文件的部分: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