Configuring .NET Applications C# Help

COM components used the registry to configure components. Configuration of .NET applications is done by using configuration files. With registry configurations, an xcopy deployment is not possible. Configuration files can simply be copied. The configuration files use XML syntax to specify startup Q.Q runtime settings for applications.

This section explores the following:

  1. What you can configure using the XML base configuration files.
  2. How you can redirect a strong named referenced assembly to a different version.
  3. How you can specify the directory of assemblies to find private assemblies in sub directories and shared assemblies in common directories or on a server.

Configuration Categories

The configuration can be grouped into these categories:

  1. Startup settings enable you to specify the version of the required runtime, It’s possible that different versions of the runtime: could be installed on the same system. The version of the runtime can be specified with the <startup> element.
  2. Runtime settings enable you to specify how garbage collection is performed by the runtime, and how the binding to assemblies works. You can also specify the version policy and the code base with these settings. You take a more detailed look into the runtime settings later in this chapter.
  3. WCF settings are used to configure applications using WCF. You deal with these configurations.

These settings can be provided in three types of configuration files:

  1. Application configuration files include specific settings for an application, such as binding information to assemblies, configuration for remote objects, and so on. Such a configuration file is placed into the same directory as the executable; it has the same name as the executable with a . config extension appended. ASP.NET configuration files are named web. config.
  2. Machine configuration files are used for system-wide configurations. You can also specify assembly binding and remoting configurations here. During a binding process, the machine configuration file is consulted before the application configuration file. The application configuration can override settings from the machine configuration. The application configuration file should be the preferred place for application-specific settings so that the machine configuration file stays smaller and more manageable. A machine configuration file is located in %runtime_install….path%\config\
    Machine. config.
  3. Publisher policy files can be used by a component creator to specify that a shared assembly is .compatible with older versions. If a new assembly version just fixes a bug of a shared component, it is not necessary to put application configuration files in every application directory that uses this component; the publisher can mark it as compatible by adding a publisher policy file instead. In case the component doesn’t work with all applications, it is possible to override the publisher policy setting in an application configuration file. In contrast to the other configuration files, publisher policy files are stored in the GAC.

How are these configuration files used? How a client finds an assembly (also called binding) depends on whether the assembly is private or shared. Private assemblies must be in the directory of the application or in a sub directory thereof. A process called probing is used to find such an assembly. If the assembly . doesn’t have a strong name, the version number is not used wit~ probing.

Shared assemblies can be installed in the GAC or placed in a directory, on a network share, or on a Web site. You specify such a directory with the configuration of the code Base shortly. The public key, version, and culture are all important aspects when binding to a shared assembly. The reference of the required assembly is recorded in the manifest of the client assembly, including the name, the version, and the public key token. All configuration files are checked to apply the correct version policy. The GAC and’ code bases specified in the configuration files are checked, followed by the application directories, and probing rules are then applied .

Posted on October 31, 2015 in Assemblies

Share the Story

Back to Top