Application Configuration File?

  • Thread starter Thread starter kathy
  • Start date Start date
K

kathy

What Application Configuration File is? And
when/where/how to use it? Any documents on that? MSDN has
somrthings scatter everywhere - hard to follow.

thanks,
 
Kathy,
An Application Configuration File is an XML file that .NET uses to configure
your application.

For ASP.NET applications the file is called web.config. At run time it is
still called web.config.

For Windows applications, the file is called app.config. At run time the
app.config is called myexe.exe.config and need to be in the same directory
as the exe itself.

Class libraries (.dll files) do not have an Application Configuration File,
they need to rely on either the web.config or the app.config.

When you use 'Project - Add New Item - Application Configuration File' in
VS.NET to add one to your project it will be named either app.config or
web.config per above. At runtime it will be moved to the appropriate folder
and used.

There is also a machine.config file, that .NET uses to configure your
application. This file is merged with the app.config with the app.config
getting precedence. In other words you can use the machine.config to have
global settings that are shared across apps, then use the app.config to
override some of these settings.

The two primary sections of the app.config are configSections and
appSettings. appSettings is a predefined section that allows you to define
name/value pairs. You use
System.Configuration.ConfigurationSettings.AppSettings to read values from
the appSettings section.

configSections allows you to define your own sections. You use
System.Configuration.ConfigurationSettings.GetConfig to retrieve these
values.

See the following for create new sections via the configSections section.

http://msdn.microsoft.com/library/d...de/html/cpconconfigurationsectionhandlers.asp

and:
http://msdn.microsoft.com/library/d...ref/html/gngrfconfigurationsectionsschema.asp

Also read about the System.Configuration.ConfigurationSettings class and
other classes in the System.Configuration namespace.

And yes, the documentation is scattered & hard to follow...

Hope this helps
Jay
 
The intent was not to offend you which you seem to have been so my
apologies.

Good luck in your search and hope Jay's answer following mine is more
helpful.

Peace.
 
Back
Top