I added a custom section to my app.config file for a Windows Forms Application. I created the class to extend the configuration file:
CustomFields myCustomFields = (CustomFields)System.Configuration.ConfigurationManager.GetSection("CustomFields");
I specify the section name:
<section name="CustomFields" type="Application.Core.CustomFields, ATMCardRequest.Core" allowLocation="true" allowDefinition="Everywhere" />
Now here is where I think the issue is. The above has worked fine before but I need a lot of properties for this section and instead of doing this:
<CustomFields setting1='hello' setting2='world'/>
I am doing this:
<CustomFields>
<property name="setting1">hello</property>
<property name="setting2">world</property>
...
</CustomFields>
Code:
/// <summary>
/// Settings file which holds the name of the XML Fields
/// </summary>
public class setting1: ConfigurationSection
{
/// <summary>
/// Name of the setting1 Field
/// </summary>
[ConfigurationProperty("setting1", IsRequired = true)]
public String setting1
{
get
{
return (String)this["setting1"];
}
set
{
this["setting1"] = value;
}
}
/// <summary>
/// Name of the setting2 Field
/// </summary>
[ConfigurationProperty("setting2",IsRequired = true)]
public String setting2
{
get
{
return (String)this["setting2"];
}
set
{
this["setting2"] = value;
}
}
}
}
Which isn't working. Apparently it doesn't understand the 'property' syntax.
Any ideas what I am doing wrong? Thanks.