DenaliHardtail
DenaliHardtail

Reputation: 28316

How do I change the display name of a custom ConfigurationSection?

I'm building a custom ConfigurationSection for use in a demo application. The name I gave the class inheriting from ConfigurationSection is the section name the application looks for in the config file. How do I change this behavior?

Here's the skeleton of the class inheriting from ConfigurationSection:

public class LongNameBecauseItsTheResultOfFollowingAnOtherwiseGoodConvention: ConfigurationSection
{
   ...    
}

And in the app.config file it wants to see the following section:

<LongNameBecauseItsTheResultOfFollowingAnOtherwiseGoodConvention>
  ...
</LongNameBecauseItsTheResultOfFollowingAnOtherwiseGoodConvention>

How can I use a shorter section name in the app.config yet follow our convention in the source code?

Upvotes: 1

Views: 58

Answers (1)

DenaliHardtail
DenaliHardtail

Reputation: 28316

When defining the ConfigurationSection in the <configSections> element of the app.config file, you can assign a different name.

<configuration>
  <configSections>
    <section name="ABC123" type="namespaceName.className, assemblyName"/>
  </configSections>
</configuration>

Upvotes: 1

Related Questions