I have a strange problem that I cannot understand. I have my own settings class that inherits ApplicationSettingsBase. It has user area settings as shown below.
[UserScopedSettingAttribute()]
public AccountKeyClass ActiveAccount
{
get
{
try
{
return (AccountKeyClass)this["ActiveAccount"];
}
catch(Exception error){}
return null;
}
set
{
this["ActiveAccount"] = value;
if (!this.AccountList.Contains(value))
{
}
}
}
[UserScopedSettingAttribute()]
public List<AccountKeyClass> AccountList
{
get
{
try
{
if(this["AccountList"] != null)
return (List<AccountKeyClass>)this["AccountList"];
}
catch(Exception error){}
return null;
}
set { this["AccountList"] = value; }
}
I have two forms: the main form and the settings form, in which you can change the application settings. When I create a SettingsForm and change the value of AccountList, the user.config file changes as excluded. My Apply / Ok button for my Form settings calls Settings.Save (), then Settings.Reload () closes the form. The problem is that when .Reload () is called, the Settings.AccountList list becomes null.
, user.config , , user.config - , Settings.AccountList .
Settings.AccountList , .Reload().
Update:
List Save(); MainForm, AccountList user.config . AccountList (SettingsForm) Save(), , . , Reload().
, - Generic List < > . AccountKeyClass Serialized XML.