Why are application settings read-only in app.config?

The real complete answer:

The app.config settings are read-only because there are 2 types of settings:

  1. Application Settings
  2. User Settings

The first won't change unless the application publisher publishes a new version of it. The second is not stored in the app.config, but in a user.config file. In the abscence of this user.config file the app.config provides the default value.

If MySetting is a User Setting:

Settings.Default.MySetting = MyNewValue;
Settings.Default.Save();

It will create a user.config file at [User Local Settings Application Data]\[company name]\[application].exe[hash string]\[version] with the new settings, and those settings will prevail over the settings in the app.config file.


Why: Application settings are intended to be stored in the Application folder under Program Files where the user does not have write privileges.

How: There is no default support for "All Users" but you should be able to setup your own custom config file in a public folder or use a Database.


Simply put: There's no location on a machine that everyone can change, unless you give privileges to do so.

There are several ways to deal with this kind of situation:

  • You can create a configuration file / some registry settings, put this in the "all users" profile and grant "Everyone" the rights to change that specific file. During installation you can automate the procedure for granting the appropiate privileges and your program can handle the rest.

  • You can leverage UAC to make sure the current user has the appropiate privileges to change a system-wide setting. This is the recommended approach but also means that not everyone can change specific settings.

  • You can use a shared database and store your settings in there.

  • ???

I would not recommend to change items in the program files directory or changing the default privileges overthere.

EDIT: As local system you have indeed write privileges to the program files directory. If you get the "Read only" error, it means the settings itself are read only. You'll need to use the configuration manager to be able to change the settings in configuration files.

Hope this helps.