CHAPTER 14 BUILDING AND CONFIGURING CLASS LIBRARIES
Note Be very aware that the privatePath attribute cannot be used to specify an absolute
(C:\SomeFolder\SomeSubFolder) or relative (..\SomeFolder\AnotherFolder) path! If you need to specify a
directory outside the client’s application directory, you will need to use a completely different XML element named
(more details on this element later in the chapter).
Multiple subdirectories can be assigned to the privatePath attribute using a semicolon-delimited
list. You have no need to do so at this time, but here is an example that informs the CLR to consult the
MyLibraries and MyLibraries\Tests client subdirectories:
Next, for testing purposes, change the name of your configuration file (in one way or another) and
attempt to run the program once again. The client application should now fail. Remember that *.config
files must be prefixed with the same name as the related client application. By way of a final test, open
your configuration file for editing and capitalize any of the XML elements. Once the file is saved, your
client should fail to run once again (as XML is case sensitive).
Note Understand that the CLR will load the very first assembly it finds during the probing process. For example,
if the C:\MyApp folder did contain a copy of CarLibrary.dll, it will be loaded into memory, while the copy under
MyLibraries is effectively ignored.
The Role of the App.Config File
While you are always able to create XML configuration files by hand using your text editor of choice,
Visual Studio allows you create a configuration file during the development of the client program. The
first step is to elect to insert a new Application Configuration file item into your project via the Project
Add New Item menu option. Notice in Figure 14-11, you have left the name of this file as the suggested
App.config.
529