Reputation: 115
I'm currently using the below code to add a setting to my settings file, but keep getting the following error:
The type 'providercollection' is defined in an assembly that is not referenced. You must add a reference to assembly" at this line: Properties.Settings.Default.Providers["LocalFileSettingsProvider"];
How can I fix this error? Thanks in advance.
System.Configuration.SettingsProperty property = new System.Configuration.SettingsProperty("CustomSetting");
property.DefaultValue = "Default";
property.IsReadOnly = false;
property.PropertyType = typeof(string);
property.Provider = Properties.Settings.Default.Providers["LocalFileSettingsProvider"];
property.Attributes.Add(typeof(System.Configuration.UserScopedSettingAttribute), new System.Configuration.UserScopedSettingAttribute());
Properties.Settings.Default.Properties.Add(property);
Upvotes: 1
Views: 214
Reputation: 69
You can do this:
Upvotes: 1