Chapter 37

Configuration Files

WHAT’S IN THIS CHAPTER?

  • Understanding the .NET configuration system
  • Using configuration files within your application
  • Storing custom types in configuration files

One of the challenges to build applications is adjusting the way the application functions on-the-fly without having to rebuild it. There’s a long history of applications using configuration files to control the way an application runs. .NET applications use a series of XML configuration files that can be adjusted to determine application behavior. This chapter explores the structure of these configuration files and demonstrates how you can store custom information using a configuration section handler.

.CONFIG FILES

The .NET Framework configuration system consists of several configuration files (discussed in the following sections) that can be used to adjust one or more applications on a computer system. Part of this system is an inheritance model that ensures that configurations can be applied at the appropriate level. This model is such that sections defined in a configuration file at a lower level override the same sections specified in a file higher up the chain. If no configuration file defines a value or section, the default values are taken from the schema files to which the configuration files must adhere.

Machine.Config

At the root of the inheritance model is the machine.config file (located in the systemroot\Microsoft .NET\Framework\versionNumber\CONFIG\ folder, or systemroot\Microsoft ...

Get Professional Visual Studio 2012 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.