Reputation: 28316
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
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