App.Config vs Custom XML File

I read a lot of statements like "you should not clutter your app.config file with user settings." However, I got the impression that this was exactly the purpose of the file?

Is this really a preference? Or are there any real benefits (other than sharing settings) with a custom XML file, as indicated in the app.config file? If you need to explicitly specify parameters, is it better to use a custom ConfigurationSection instead of choosing a custom XML file?

I would like other people to think about it.

+6
application-settings app-config
Oct. 14 '09 at 12:18
source share
5 answers

Some people tend to struggle a bit with custom configuration section handlers, in my humble opinion.

I only use them when I need something very structured; and this is used / written by third parties (i.e. I want to do some extravagant check on it).

I think that you can well use app.config / web.config for all the relevant parameters and use separate XML files when it is very clear that this is a separate component of the application.

+5
Oct. 14 '09 at 12:26
source share

Look at the Application Parameter Architecture , app.config is for configuring the application, but this is a pretty general term. Therefore, I suggest you familiarize yourself with the application settings files.

I will not store settings such as "load the database at startup or not" in app.config. I would prefer to use alternative storage options, such as application settings, do not confuse the application configuration with the settings, even if you can do it, Do not. App.config is supposed to have a lower level configuration, such as a database connection, a membership provider, or any other information about the criticism of the application.

+5
Oct 14 '09 at 12:23
source share

Most settings usually fall into one of three camps:

  • Technical parameters that affect the internal behavior of the code, for example. database connection string, data file path, registration keys, error switches, etc.
  • Business settings that affect the business logic of a product, for example. "are users allowed access to the CRM module?"
  • User profile values, for example. "Did this user allow access to the CRM module?".

The natural place for type 1 is in app.config or web.config , and the natural place for types 2 and 3 is in the database.

+2
Oct 14 '09 at 12:34
source share

App.Config is good for application-specific configuration: a good example is the database path. The rest should be outside of this.

One thing you might want to do is create custom files, then you can use custom xml, which will be stored in isolated storage.

+1
Oct 14 '09 at 12:22
source share

In my opinion, I find app.config good for deployment time parameters like database location or IP address or location of critical data file etc. User preferences, such as font, color, behavior preferences, should go to another file that you can easily create and save using Xml serialization.

+1
Oct. 14 '09 at 12:25
source share



All Articles