Home > .Net > Why have machine.config and the application config file?

Why have machine.config and the application config file?

Put simply machine.config has default settings for all applications on your machine, and the application configuration file has settings just for the application. The application settings override the settings in machine.config.

The technical explanation requires looking at the Create method of IConfigurationSectionHandler. This method is implemented by all configuration section handlers and looks like this:

object Create(object parent, object configContext, XmlNode section);

The section parameter is the XML for that section, the configContext parameter is only relevant to ASP.NET and will be ignored here. GetConfig will call this twice: once for the section in machine.config and then once more for the section in the application config file. The handler should process the XML and use this information to create a configuration object which is returned from Create. If the call to Create for machine.config returns a configuration object, then this object is passed as the parent parameter to the subsequent call to Create for the application config file. It's entirely up to the handler to determine what it must do with this parent object, but clearly the most logical thing to do is to use the values as default values and if there are equivalent values in the application configuration file, then the parent values will be overwritten.

Categories: .Net
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: