I implemented ApplicationSettingsBase as follows:
public class UserSettings : ApplicationSettingsBase
{
private static UserSettings defaultInstance = ((UserSettings)(ApplicationSettingsBase.Synchronized(new UserSettings())));
public static UserSettings Default
{
get
{
return defaultInstance;
}
}
[UserScopedSetting()]
public string MyProperty
{
get { return (string)this["MyProperty"]; }
set { this["MyProperty"] = (string)value; }
}
}
And added the correct xml to app.config ...
see http://msdn.microsoft.com/en-us/library/8eyb2ct1(VS.80).aspx
and it works. NTN!
Warning! The ApplicationSettingsBase seems to use some lazy loading in the implementation. Collections ApplicationSettingsBase.Propertiesand ApplicationSettingsBase.PropertyValuesremain empty until it is available at least one property.
UserSettings settings = new UserSettings();
string temp = settings.MyProperty;//without this line, settings.PropertyValues is empty!!
SettingsPropertyValueCollection properties = settings.PropertyValues;
source
share