in .NET 3.5. It covered LINQ's four key implementations: LINQ to Objects, LINQ to XML, LINQ to Dataset, and LINQ to SQL. LINQ enables you to query various types of data sources, using a unified query language, making data access easy and efficient.
Chapter 15
Assemblies and Versioning
In .NET, the basic unit deployable is called an assembly. Assemblies play an important part of the development process where understanding how they work is useful in helping you develop scalable, efficient .NET applications. This chapter explores:
□ The components that make up a .NET assembly
□ The difference between single-file and multi-file assemblies
□ The relationships between namespaces and assemblies
□ The role played by the Global Assembly Cache (GAC)
□ How to develop a shared assembly, which can be shared by other applications
Assemblies
In .NET, an assembly takes the physical form of an EXE (known as a process assembly) or DLL (known as a library assembly) file, organized in the Portable Executable (PE) format. The PE format is a file format used by the Windows operating system for storing executables, object code, and DLLs. An assembly contains code in IL (Intermediate Language; compiled from a .NET language), which is then compiled into machine language at runtime by the Common Language Runtime (CLR) just-in-time compiler.
Structure of an Assembly
An assembly consists of the following four parts (see Figure 15-1).
Part | Description |
---|---|
Assembly metadata | Describes the assembly and its content |
Type metadata | Defines all the types and methods exported from the assembly |
IL code | Contains the MSIL code compiled by the compiler |
Resources | Contains icons, images, text strings, as well as other resources used by your application |

Figure 15-1
Physically, all four parts can reside in one physical file, or some parts of an assembly can be stored other

Figure 15-2
An assembly is the basic unit of installation. In this example, the assembly is made up of three files (one assembly and two modules). The two modules by themselves cannot be installed separately; they must accompany the assembly.
Examining the Content of an Assembly
As mentioned briefly in Chapter 1, you can use the MSIL Disassembler tool (ildasm.exe
) to examine the content of an assembly. Figure 15-3 shows the tool displaying an assembly's content.

Figure 15-3
Among the various components in an assembly, the most important is the manifest (shown as MANIFEST in Figure 15-3), which is part of the assembly metadata. The manifest contains information such as the following:
□ Name, version, public key, and culture of the assembly
□ Files belonging to the assembly
□ References assemblies (other assemblies referenced by this assembly)
□ Permission sets
□ Exported types
Figure 15-4 shows the content of the manifest of the assembly shown in Figure 15-3.

Figure 15-4
Single and Multi-File Assemblies
In Visual Studio, each project that you create will be compiled into an assembly (either EXE or DLL). By default, a single-file assembly is created. Imagine you are working on a large project with 10 other programmers. Each one of you is tasked with developing part of the project. But how do you test the system as a whole? You could ask every programmer in the team to send you his or her code and then you could compile and test the