The application configuration file, sometimes referred to as app.cfg, is an XML file that contains a several attributes that can control the binding behavior of the application. This section describes each of the attributes in the application configuration file.
The terminology used in the application configuration file is consistent with the other configuration files. A collection defines the beginning of a set of rows, and is delineated by start and end tags, such as: <tag>
and </tag>
. A row is an entry inside a collection which contain specific settings in the form of name-value pairs. A property is a name-value pair inside a row that contains the setting information.
The outer-most collection that defines the application configuration file is the Configuration
collection. Each of the sub-collections and rows described below appears between the start and end tags of the Configuration collection.
Under the Configuration
collection, an AppDomain
row can provide information on different locations of assemblies. Specifically, the AppDomain
row contains properties that can be used to specify a shared and private binpath that is appended to the binpath provided during a bind operation. There is an additional property, called ShadowCopy,
that is used by the runtime to determine whether or not to copy the assembly into the download cache even if the assembly can be run from the source location.
For example:
<AppDomain PrivatePath="[semicolon delimited private binpath]" ShadowCopy="[True|False]"/>
The BindingMode
collection contains a single row that describes the “binding mode” for the application. This row, named AppBindingMode
has a single property called Mode
that can be set to one of two values: “safe” and “normal”. (so what do they mean??) If a value for the Mode
property is not “safe” or “normal”, the binding mode is assumed to be “normal”.
For example:
<BindingMode> <AppBindingMode Mode="[safe|normal]"/> </BindingMode>
The BindingPolicy
collection contains BindingRedir
rows that redirect one version of an assembly to another. This version redirection, or policy only applies to shared assemblies (ie. assemblies which contain a public key). The BindingRedir
row contains a number of properties, which are listed below:
Property Name | Supported Values | Description |
---|---|---|
Name | Any string | Name of the assembly |
Originator | String form of originator, an eight-byte has of the public key | Originator of the assembly |
Version | String form of version: w.x.y.z, or “*” for all versions | Version which should be redirected |
VersionNew | String form of version: w.x.y.z | Version which the assembly should be redirected to |
UseLatestBuildVersion | “yes” or “no” | Indicates whether or not this assembly should be subject to automatic QFE updates from the global cache |
For example:
<BindingPolicy> <BindingRedir Name="[name]" Originator="[orig]" Version="[ver|*]" VersionNew="[ver]" UseLatestBuildRevision="[yes|no]"/> </BindingPolicy>
The Assemblies
collection contains one or more CodeBaseHint
rows, which can tell the runtime where to find a particular assembly. These codebase “hints” are always attempted before the standard runtime probing occurs. The CodeBaseHint
row contains a number of properties which describe the assembly, as well as the location where the assembly can be found:
Property Name | Supported Values | Description |
---|---|---|
Name | Any string | Name of the assembly |
Originator | String form of the originator, the eight-byte hash of the public key | Originator of the assembly |
Version | String form of version: w.x.y.z | Version of assembly |
CodeBase | String containing a valid URL | Codebase URL where the assembly can be found |
For example:
<Assemblies> <CodeBaseHint Name="[name]" Originator="[orig]" Version="[ver]" CodeBase="[URL]"/> </Assemblies>
The following is an example of an application config file. This file contains settings for the web server in addition to version policy and codebase settings.
<?xml version ="1.0"?> <Configuration> <AppDomain PrivatePath="bin;bin2;foo" ShadowCopy="True" /> <BindingMode> <AppBindingMode Mode="normal"/> </BindingMode> <BindingPolicy> <BindingRedir Name="g_SglAsm_SglMod1.dll" Originator="8e47bf1a5ed0ec84" Version="*" VersionNew="3.3.3.3" UseLatestBuildRevision="no"/> </BindingPolicy> <Assemblies> <CodeBaseHint Name="g_SglAsm_SglMod1.dll" Originator="8e47bf1a5ed0ec84" Version="3.3.3.3" CodeBase="http://codebasehint/Mydll.dll"/> </Assemblies> </Configuration>