CHAPTER 14 BUILDING AND CONFIGURING CLASS LIBRARIES
CIL Code, Type Metadata, and the Assembly Manifest
At its core, an assembly contains CIL code, which, as you recall, is a platform- and CPU-agnostic
intermediate language. At runtime, the internal CIL is compiled on the fly using a just-in-time (JIT)
compiler, according to platform- and CPU-specific instructions. Given this design, .NET assemblies can
indeed execute on a variety of architectures, devices, and operating systems. (Although you can live a
happy and productive life without understanding the details of the CIL programming language, Chapter
18 offers an introduction to the syntax and semantics of CIL.)
An assembly also contains metadata that completely describes the format of the contained types, as
well as the format of external types referenced by this assembly. The .NET runtime uses this metadata to
resolve the location of types (and their members) within the binary, lay out types in memory, and
facilitate remote method invocations. You’ll check out the details of the .NET metadata format in
Chapter 15 during our examination of reflection services.
An assembly must also contain an associated manifest (also referred to as assembly metadata). The
manifest documents each module within the assembly, establishes the version of the assembly, and also
documents any externa l assemblies referenced by the current assembly. As you will see over the course
of this chapter, the CLR makes extensive use of an assembly’s manifest during the process of locating
external assembly references.
Optional Assembly Resources
Finally, a .NET assembly may contain any number of embedded resources, such as application icons,
image files, sound clips, or string tables. In fact, the .NET platform supports satellite assemblies that
contain nothing but localized resources. This can be useful if you want to partition your resources based
on a specific culture (English, German, etc.) for the purposes of building international software. The
topic of building satellite assemblies is outside the scope of this text; consult the .NET 4.5 Framework
documentation for information on satellite assemblies if you are interested.
Building and Consuming Custom Class Library
To begin exploring the world of .NET class libraries, you’ll first create a *.dll assembly (named
CarLibrary) that contains a small set of public types. To build a code library using Visual Studio, select
the Class Library project workspace via the File New Project… menu option (see Figure 14-2).
514