Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

FIX: AppContext switch overrides are not applied to applications that run on the .NET Framework 4.7


View products that this article applies to.

Symptoms

Assume that you have Microsoft .NET Framework 4.7 installed on a computer. You may notice that the applications that run on the .NET Framework don't respect the compatibility settings that are specified in the registry for AppContext switches. In this scenario, when you try to set a registry option for an AppContext flag, it behaves as if the value that's specified in the registry option is set to False.

↑ Back to the top


Cause

When the program reads the value of an AppContext switch in the registry, the data cannot be retrieved. In this case, it is assumed that something is wrong with the way the setting is specified in the registry, and a value of False is returned to the application.

↑ Back to the top


Resolution

To fix this issue, use the application configuration (app.config) file to set the flag to the desired value.

Add an <AppContextSwitchOverrides> element to the <runtime> section of the app.config file. The switch has a single attribute, that is, value, whose value is a string that represents a key or value pair that contains both the switch name and the value.

To define multiple switches, separate each switch's key or value pair in the <AppContextSwitchOverrides> element's value attribute with a semicolon. In that case, the <AppContextSwitchOverrides> element has the following format:

XML

<AppContextSwitchOverrides value=”switchName1=value1;switchName2=value2” />

Using the <AppContextSwitchOverrides> element to define a configuration setting has the application scope. That is, it affects only the application.

Because app.config files are application specific, you must do this for all affected applications.

For more information about AppContext, go to the following topic on the Microsoft Developer Network (MSDN) website:

AppContext Class

↑ Back to the top


More Information

This issue was introduced as part of the work to enable AppContext switches to be used very early in the AppDomain life cycle. This allowed changes that would otherwise be breaking to be done safely, even if the code that needed to use an AppContext switch ran very early in the AppDomain bring-up.

The issue is about how much memory is allocated to store the value that's read from the registry. If the allocated space to store the value that's read from the registry is insufficient, it will fall back to the default value of False. 

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section and Microsoft is working on a solution in the upcoming versions of the product.

↑ Back to the top


Keywords: kbqfe, kbfix, kbsurveynew, kbexpertiseadvanced, kb

↑ Back to the top

Article Info
Article ID : 4036977
Revision : 8
Created on : 7/28/2017
Published on : 7/28/2017
Exists online : False
Views : 458