I am trying to get my application settings to save when a user exits a configuration form (not my mainform). It will keep the settings in memory because when I open the form again, it will have my data that I configured still there, but it will not save it to disk. This is the filepath it is saving the xml file to
C:\Users\david_000\AppData\Local[company name][project name]\1.0.0.0.
I am using [UserScopedSetting()] in my class that implements the ApplicationSettingsBase file, so it should save when I call,
Properties.Settings.Default.Save();
This is my class that uses ApplicationSettingsBase
public class DeviceConfiguration : ApplicationSettingsBase
{
/// <summary>
/// Initializes a new instance of the <see cref="DeviceConfiguration"/> class.
/// </summary>
public DeviceConfiguration()
: base()
{
this.MasterDevices = new BindingList<Device>();
this.SlaveDevices = new BindingList<Device>();
}
[UserScopedSetting()]
[SettingsSerializeAs(System.Configuration.SettingsSerializeAs.Xml)]
public BindingList<Device> MasterDevices
{
get
{
return this["MasterDevices"] as BindingList<Device>;
}
set
{
this["MasterDevices"] = value;
}
}
[UserScopedSetting()]
[SettingsSerializeAs(System.Configuration.SettingsSerializeAs.Xml)]
public BindingList<Device> SlaveDevices
{
get
{
return this["SlaveDevices"] as BindingList<Device>;
}
set
{
this["SlaveDevices"] = value;
}
}
}
My BindingList contains multiple properties and that class is using the [Serializable] attribute. But when I save the xml file, all it saves is this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<userSettings>
<[company.project].Properties.Settings>
<setting name="IpAddressBESS" serializeAs="String">
<value>192.168.3.254</value>
</setting>
<setting name="PortBESS" serializeAs="String">
<value>504</value>
</setting>
<setting name="IpAddressInverter" serializeAs="String">
<value>192.168.3.200</value>
</setting>
<setting name="PortInverter" serializeAs="String">
<value>502</value>
</setting>
<setting name="StartDate" serializeAs="String">
<value>04/08/2015 08:00:00</value>
</setting>
<setting name="EndDate" serializeAs="String">
<value>04/08/2015 16:00:00</value>
</setting>
<setting name="DeviceConfig" serializeAs="Xml">
<value />
</setting>
</[company.project].Properties.Settings>
</userSettings>
</configuration>
Any advice on this would be greatly appreciated.