Free mag vol1 | Page 609

CHAPTER 14  BUILDING AND CONFIGURING CLASS LIBRARIES Given that CarLibrary.dll has been deployed to the GAC, you are able to run the program as is. However, to illustrate the use of the element, create a new folder under your C: drive (perhaps C:\MyAsms) and place a copy of CarLibrary.dll version 2.0.0.0 into this directory. Now, add an App.config file (or edit an existing App.config) to the CodeBaseClient project (as explained earlier in this chapter) and author the following XML content (remember that your .publickeytoken value will differ; consult your GAC as required): ... As you can see, the element is nested within the element, which makes use of the name and publicKeyToken attributes to specify the friendly name and associated publicKeyToken values. The element itself specifies the version and location (via the href property) of the assembly to load. If you were to delete version 2.0.0.0 of CarLibrary.dll from the GAC, this client would still run successfully, as the CLR is able to locate the external assembly under C:\MyAsms.  Note If you place assemblies at random locations on your development machine, you are in effect re-creating the system registry (and the related DLL hell), given that if you move or rename the folder containing your binaries, the current bind will fail. With that in mind, use with caution. The element can also be helpful when referencing assemblies located on a remote networked machine. Assume you have permission to access a folder located at http://www.MySite.com. To download the remote *.dll to the GAC’s download cache on your local machine, you could update the element as follows:  Source Code The CodeBaseClient application can be found under the Chapter 14 subdirectory. 551