docs
docs copied to clipboard
No Documentation on Settings Sections
There is no documentation included on this page for how the name for the element WindowsApplication1.Properties.Settings
is determined.
Based on my testing, it seems that the expected name for this tag is the namespace and class name in the file generated by settings designer.
However, it is not clear to me what name should be used for the tag in the case that I am creating new application settings programmatically (without the designer) as documented here: https://docs.microsoft.com/en-us/dotnet/framework/winforms/advanced/how-to-create-application-settings#to-create-new-application-settings-programmatically
For example, if I create a settings class WindowsApplication1.Properties.MyCustomSettings : ApplicationSettingsBase
, what would I put as the section tag name directly under <applicationSettings>
? Using <WindowsApplication1.Properties.MyCustomSettings>
which I would expect to work results in an error while parsing the config file:
ConfigurationErrorsException: Unrecognized configuration section applicationSettings/WindowsApplication1.Properties.MyCustomSettings.
Some additional guidance on how the name for this XML element is determined would definitely be helpful because right now it is not explained anywhere in the documentation that I can find.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 6d9e9e1d-4c41-8d0a-c39e-279eaf345522
- Version Independent ID: eb9c64ad-e3cb-311f-d17e-3622dab460b8
- Content: Application Settings schema
- Content Source: docs/framework/configure-apps/file-schema/application-settings-schema.md
- Product: dotnet-framework
- GitHub Login: @dotnet-bot
- Microsoft Alias: dotnetcontent
Thank you for opening this issue. I'll add it to the backlog.
The values allowed under <applicationSettings>
need to be defined by adding an entry to the <configSections>
element.
So you need to provide that definition at the top of the config file. After recreating your example, here is what my config section looked like.
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="WindowsFormsApp1.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="WindowsFormsApp1.Properties.MyCustomSettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
... more xml ...
Thanks again!
NOTE When fixing this issue
- the article this issue is on should mention the link between defining a config section and then providing that section.
- The How to create new Application Settings programmatically article should show the config file and mention that you need to add entries into the app config to wire this up, otherwise, settings never load.
This issue has been closed as part of the issue backlog grooming process outlined in #22351.
That automated process may have closed some issues that should be addressed. If you think this is one of them, reopen it with a comment explaining why. Tag the @dotnet/docs
team for visibility.
We still get a lot of requests for folks not understanding why they get these exceptions in .NETCore. It would be helpful to have documentation covering the limitations of System.Configuration.ConfigurationManger in .NETCore and what to use instead.
cc @dotnet/area-system-configuration
An important thing to cover here -- most configuration sections which were defined by .NETFramework are no longer functional in .NETCore. System.Configuration.ConfigurationManager is only provided for compatibility.
Most people who hit this issue - the right thing to do is to remove the usage in app.config and call API to make the same setting (or use the new Configuration API if their component supports it).
It might be worthwhile enumerating all the ConfigurationSections in .NETFramework and listing out the replacement API in .NETCore (if available).