CHAPTER 14 BUILDING AND CONFIGURING CLASS LIBRARIES
If you run the current SharedCarLibClient.exe program by double-clicking the icon in Windows
Explorer, you should not see the “CarLibrary Version 2.0!” message box appear, as the manifest is
specifically requesting version 1.0.0.0. How then can you instruct the CLR to bind to version 2.0.0.0? Glad
you asked!
Note Visual Studio will automatically reset references when you compile your applications! Therefore, if you run
your SharedCarLibClient.exe application within Visual Studio, it will grab CarLibrary.dll version 2.0.0.0! If
you accidentally ran your application in this way, simply delete the current CarLibrary.dll reference and select
version 1.0.0.0 (which I suggested you place in a folder named CarLibrary Version 1.0.0.0).
Dynamically Redirecting to Specific Versions of a Shared Assembly
When you want to tell the CLR to load a version of a shared assembly other than the version listed in the
manifest, you can build a *.config file that contains a element. When doing so,
you will need to create an subelement that specifies the friendly name of the
assembly listed in the client manifest (CarLibrary, for this example) and an optional culture attribute
(which can be assigned an empty string or omitted altogether if you wish to use the default culture for
the machine). Moreover, the element will define a subelement
to define the version currently in the manifest (via the oldVersion attribute) and the version in the GAC
to load instead (via the newVersion attribute).
Update the current configuration file in the application directory of SharedCarLibClient named
SharedCarLibClient.exe.config that contains the following XML data.
Note The value of your public key token will be different from what you see in the following markup. To find
your public key token value, recall you can open the client into ildasm.exe, double click the MANIFEST icon, and
copy the value to your clipboard (just be sure to remove the blank spaces!).
547