15.1 The Configuration Files
Each of the .NET configuration files shares a common XML format,
although their scopes differ depending on which location the file is
in. Some of the files are installed and configured automatically when
the framework is installed.
Although the contents of the files differ, they share a common
schema. The root element of each file is the
configuration element, although different elements
will appear as child nodes in the different files. Because the
configuration files are all XML, you can deal with them as you would
any XML document, including editing them with a text editor, or using
the classes in the System.Xml namespace to
manipulate them.
 |
Although you can edit the configuration file as much as you want, be
sure to note that you're just editing the file on
disk. No changes you make on disk will affect the configuration
settings once they've been read into the
configuration system by a running application.
|
|
15.1.1 The Security Configuration Files
There are several different security policy configuration files: the
enterprise security policy configuration file in %windir%\Microsoft.NET\Framework\v%version%\CONFIG\enterprisesec.config,
the machine security policy configuration file in %windir%\Microsoft.NET\Framework\v%version%\CONFIG\security.config,
and the user security policy configuration file in %userprofile%\Applicationdata\Microsoft\CLRsecurity
config\v%version%\security.config (for Windows 2000 and
Windows NT) or %windir%\username\CLRsecurityconfig\v%version%\security.config (for Windows 98 and
Windows Me). There may also be web_hightrust.config, web_lowtrust.config, and web_notrust.config files in the %windir%\Microsoft.NET\Framework\v%version%\CONFIG
directory.
The security policy files contain configuration settings that pertain
to security for particular assemblies. It is strongly recommended
that you do not edit these files directly, instead using the .NET
Framework Configuration tool (mscorcfg.msc) or
Code Access Security Policy tool (caspol.exe) to
edit security policies. For more information on configuring .NET
security policies, see .NET Framework Security
by Brian A. LaMacchia, Sebastian Lange, Matthew Lyons, Rudi Martin,
and Kevin T. Price (Addison Wesley).
15.1.2 The Machine Configuration File
The machine configuration file, located in %windir%\Microsoft.NET\Framework\v%version%\CONFIG\machine.config,
contains configuration settings specific to the machine it is
installed on. While most of these settings pertain to functionality
internal to the .NET Framework, it may also be used to store
configuration settings common to more than one application. If you do
use it store shared application configuration settings, you should be
careful to name your settings in a unique way. You should also take
care not to disrupt any existing machine configuration settings when
adding your own configuration settings to the machine configuration
file.
Some of the settings in this file include debugging and error message
configuration; network configuration, such as authentication details
and web proxy location; a large number of ASP.NET configuration
settings, including settings that let you specify how different web
browser platforms and versions should be recognized; and remoting
configuration. Many of the settings in the machine configuration file
may also be configured at runtime for a particular application
instance. However, changes to these settings at runtime do not
persist in the machine configuration file, nor are they shared across
different application instances.
15.1.3 The Application Configuration File
The application configuration file is the one configuration file that
you have complete control over, and it is where you should put your
application configuration settings. The application configuration
file is automatically read when necessary, and it must be located in
the same directory as the application, and named with the same name
as the application executable plus the extension .config. If your application executable is
named C:\MyApp.exe, for example,
the application configuration file must be named C:\MyApp.exe.config.
In the next section, I'll describe how you can add
your own settings to the machine or application configuration
files.
|