[ Team LiB ] |
2.1 Assemblies ExplainedAn assembly contains one or more .NET data types compiled into the Microsoft Intermediate Language (MSIL); in other words, an assembly contains the code that the common language runtime executes. The .NET Framework uses the assembly as the basic unit of deployment and versioning and, most importantly for our purposes, as the basic security boundary. In the following chapters, we will demonstrate how the .NET Framework uses assemblies to enforce security policy; in this section, however, we provide a brief overview of assemblies as a foundation for more advanced topics. Each assembly consists of the following:
There are two types of assembly; each type differs in where the assembly contents are stored. The simplest and most common type is a single-file assembly, where all of the assembly contents are stored in a single file. As shown by Figure 2-1, the four assembly components are contained in the file named SingleFileAssembly.dll. Figure 2-1. A single-file assembly contains all of the assembly contents in a single disk fileThe second assembly type is a multifile assembly, where the contents of the assembly are stored in more than one file, as illustrated by Figure 2-2. Figure 2-2. A multifile assembly stores the assembly contents in more than one fileIn a multifile assembly, the assembly metadata and any resources are stored in one file (MultiFileAssembly.dll in Figure 2-1), while the MSIL code is contained in one or more modules, each of which contains one or more data types and any associated type metadata. The assembly is made up of all three files, which must be deployed together; there is no association between the files enforced by the filesystem—the relationship between the files is described by the file list element of the assembly metadata. The advantage of a multifile assembly is that each module can contain types written in a different .NET language; in Figure 2-2, we illustrate this by including the CSharpCode.netmodule and VBCode.netmodule files in the assembly, representing data types written in C# and Visual Basic .NET, respectively. In the next section, we demonstrate how to create an assembly using modules written in different languages.
Each assembly can have one of three "flavors," depending on the intended function of the assembly, summarized as follows:
This brief overview of assemblies should provide you with enough information to understand the rest of this chapter and the content presented in the rest of this book. Chapter 4 provides more information about the role of assemblies in the life cycle of a .NET application. |
[ Team LiB ] |