CHAPTER 14 BUILDING AND CONFIGURING CLASS LIBRARIES
{ ... }
An explicit load request occurs programmatically using the Load() or LoadFrom() method of the
System.Reflection.Assembly class type, typically for the purposes of late binding and dynamic
invocation of type members. You’ll examine these topics further in Chapter 15, but for now you can see
an example of an explicit load request in the following code:
// An explicit load request based on a friendly name.
Assembly asm = Assembly.Load("CarLibrary");
In either case, the CLR extracts the friendly name of the assembly and begins probing the client’s
application directory for a file named CarLibrary.dll. If this file cannot be located, an attempt is made
to locate an executable assembly based on the same friendly name (for example, CarLibrary.exe). If
neither file can be located in the application directory, the runtime gives up and throws a
FileNotFoundException exception at runtime.
Note Technically speaking, if a copy of the requested assembly cannot be found within the client’s application
directory, the CLR will also attempt to locate a client subdirectory with the exact same name as the assembly’s
friendly name (e.g., C:\MyClient\CarLibrary). If the requested assembly resides within this subdirectory, the
CLR will load the assembly into memory.
Configuring Private Assemblies
While it is possible to deploy a .NET application by simply copying all required assemblies to a single
folder on the user’s hard drive, you will most likely want to define a number of subdirectories to group
related content. For example, assume you have an application directory named C:\MyApp that contains
CSharpCarClient.exe. Under this folder might be a subfolder named MyLibraries that contains
CarLibrary.dll.
Regar F