I am trying to create a custom configuration section in the app.config file of my C # .NET console application. It stores some information about some servers, for example:
<configSections>
<sectionGroup name="serverGroup">
<section name="server" type="RPInstaller.ServerConfig" allowLocation="true" allowDefinition="Everywhere"/>
</sectionGroup>
</configSections>
<serverGroup>
<server>
<name>rmso2srvm</name>
<isBatchServer>false</isBatchServer>
</server>
<server>
<name>rmsb2srvm</name>
<isBatchServer>true</isBatchServer>
</server>
</serverGroup>
I have a class defined for a server section as follows:
namespace RPInstaller
{
public class ServerConfig : ConfigurationSection
{
[ConfigurationProperty("name", IsRequired=true)]
public string Name {...}
[ConfigurationProperty("isBatchServer", IsRequired = true)]
public bool IsBatchServer {...}
}
}
When I try to load server partitions, I get an exception: "Partitions should appear only once in the configuration file."
How can I legally define multiple server partitions in the app.config file?
source
share