Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The current configuration system does not support user-scoped settings

I'm trying to use a settings file to store the user preferences when he/she logins on the application.

I defined them as user (scope) but I am getting

System.Configuration.ConfigurationErrorsException: The current configuration system does not support user-scoped settings.

What may be a good solution?

like image 475
chris05 Avatar asked Mar 25 '12 21:03

chris05


3 Answers

When I had this problem, it turned out that I had a reference to a dll which had a Settings.settings (or Settings.Designer.cs) file.

What happens is that when editing the Setting.settings file, upon clicking the blank line at the bottom, a new line is added with template information and a default user setting instead of application setting. This is a nice feature but you could see how after changing the template and adding your new setting, then clicking below to lose focus a new template line is added and if you are not paying attention, you accidently add a user setting. Check if you have this file in a referenced dll and remove any user settings.

enter image description here

like image 185
ninja coder Avatar answered Oct 05 '22 23:10

ninja coder


User-scoped settings are indeed not supported for a Web application. And they wouldn't work, User settings would have to be saved under the Users\<username>\... folder on the server.

You have a wide choice of web techniques:

  • persistent cookies
  • ASP.NET Membership profiles
  • your own Db
like image 30
Henk Holterman Avatar answered Oct 06 '22 00:10

Henk Holterman


You can make Application scope settings writable by simply adding a setter to the property definition in Settings.Designer.cs. For instance:

[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("AdminContext")]
public string DbContext
{
    get { return ((string)(this["DbContext"])); }
    set { this["DbContext"] = value; } }

The caveat is that the Settings.Designer.cs is auto-generated, and therefore if you use the designer UI, your setters will be overwritten.

This works in console and web applications.

like image 42
Shane K Avatar answered Oct 06 '22 00:10

Shane K