Click here to Skip to main content
15,891,248 members
Articles / Programming Languages / F#

.NET Configuration File Corrupts On Write

Rate me:
Please Sign up or sign in to vote.
4.33/5 (2 votes)
9 Nov 2021CPOL7 min read 5.2K   3  
Programmatically Adding New ConfigurationSectionGroup Corrupts Declaration Section With Multiple Group Declarations.
.NET configuration files are designed to be customized with custom sections (System.Configuration.ConfigurationSection) and section groups (System.Configuration.ConfigurationSectionGroup). To do so, developers subclass these base classes to implement their custom functionality and incorporate them into the configuration file. .NET configuration files are XML files and follow a defined schema. It is somewhat complex but the relevant schema element in this article is the declaration section at the beginning () which declares the layout and types of sections and section groups used in the configuration file. This allows the .NET configuration mechanisms to properly instantiate your custom classes with configuration information. When modifying the configuration file programmatically, sometimes the addition of new section groups corrupts the configuration file when re-written preventing it from being read in the future. This article is a case study of such a situation.

Views

Daily Counts

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions