Information Technology Reference
In-Depth Information
Configuration Files
Configuration files contain information about the application, for use by the CLR at run time.
They can instruct the CLR to do such things as use a different version of a DLL, or to look in
additional directories when searching for a DLL referenced by the program.
Configuration files consist of XML code and don't contain C# code. The details of writing
the XML code are beyond the scope of this text, but you should understand the purpose of con-
figuration files and how they are used. One way they are used is to update an application
assembly to use the new version of a DLL.
Suppose, for example, that you have an application that references a DLL in the GAC. The
identity of the reference in the application's manifest must exactly match the identity of the
DLL assembly in the GAC. If a new version of the DLL is released, it can be added to the GAC,
where it can happily coexist with the old version.
The application, however, still has embedded in its manifest the identity of the old version
of the DLL. Unless you recompile the application and make it reference the new version of the
DLL, it will continue to use the old version. That's fine, if that's what you want.
If, however, you do not want to recompile the application but want it to use the new DLL,
then you can create a configuration file telling the CLR to use the new version rather than the
old version. The configuration file is placed in the application directory.
Figure 10-17 illustrates objects in the runtime process. The MyProgram.exe application on
the left calls for version 1.0.0.0 of the MyLibrary.dll , as indicated by the dashed arrow. But the
application has a configuration file, which instructs the CLR to load version 2.0.0.0 instead.
Notice that the name of the configuration file consists of the full name of the executable file
including the extension, plus the additional extension .config .
Figure 10-17. Using a configuration file to bind to a new version
Search WWH ::




Custom Search