Description
Description
For applications that have an app.config, the <configuration><configSection>
entry may contain a <section name="system.diagnostics"
entry which is no longer allowed. If present, the entry needs to be removed.
Having a <section name="system.diagnostics"
entry causes the following exception the first time the configuration system is used:
ConfigurationErrorsException: Section or group name 'system.diagnostics' is already defined. Updates to this may only occur at the configuration level where it is defined.
For example, this app.config file:
<configuration>
<configSections>
<section name="system.diagnostics"
type="System.Diagnostics.SystemDiagnosticsSection,
System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</configSections>
contains the unnecessary entry.
Feature area: System.Configuration (app.config files)
Version
.NET 7 RC 1
Previous behavior
Specifying <section name="system.diagnostics"
was allowed and necessary if there was a later system.diagnostics
configuration section like:
<configuration>
<system.diagnostics>
However, System.Diagnostics did not yet support the feature that processes that section in order to add various listeners and other control other diagnostic features, so it was not automatically read. Only applications which had a<system.diagnostics>
section would require a <section name="system.diagnostics"
entry.
.NET Framework, however, does support processing of the "system.diagnostics" section and had an <section name="system.diagnostics"
in the machine.config file.
Thus, this issue likely only occurs for:
- Applications that were using .NET Framework and migrated to .NET.
- Manually added
<section name="system.diagnostics"
to the app.config to support manual reading of the<system.diagnostics>
section. - Upgraded to 7.0 which now has an implicit
<section name="system.diagnostics"
entry.
New behavior
System.Diagnostics now supports reading the <system.diagnostics>
section from the config file and added an implicit <section name="system.diagnostics"
entry. Having an explicit <section name="system.diagnostics"
entry in the app.config file causes a duplicate which throws ConfigurationErrorsException
.
Type of breaking change
- Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load/execute or different run-time behavior.
- Source incompatible: Source code may encounter a breaking change in behavior when targeting the new runtime/component/SDK, such as compile errors or different run-time behavior.
Reason for change
The implementation to support the feature where System.Diagnostics reads from the app.config required adding the implicit <section name="system.diagnostics"
element. See dotnet/runtime#23937 for details on the feature request.
Recommended action
The unnecessary <section name="system.diagnostics"
entry should be removed.
Feature area
Other (please put exact area in description textbox)
Affected APIs
No response