If you are reading this book just to learn about the C# language, you can now skip to the next chapter. This chapter is an "under-the-hood" look at how the Microsoft C# compiler packages your C# code when it is compiled into an executable format. The chapter will help you understand how your C# code makes calls into the .NET Framework system classes and how other programs can call your code when you make a class library. Also, if you are planning to make a C# program that will be distributed as a commercial software product or even deployed on many computers within your organization, then the material in this chapter will be very important to understand. But if you are just making a C# program for a student project or your own personal use, then much of what follows here will be interesting, but not necessary to your use of Visual C#.
When your C# program is compiled, it is packaged into an assembly. An assembly is a .NET executable program (or part of an executable program) delivered as a single unit. It is a file or set of files containing a .NET program or resources supporting a program. When you build a C# Windows or console application, the .exe file produced is an assembly. If you build a class library, the DLL (Dynamic Link Library) file produced is also an assembly.
All the code in an assembly is built, delivered, and assigned a version number as a single unit. The assembly makes the public classes, properties, and methods visible to other programs. Everything private to your program is kept inside the assembly.
This chapter explores assemblies. In particular, you look at:
A brief review of components
Features of an assembly, including its self-description ability
The structure of an assembly, and how to view its contents
Assembly versioning
Private and shared assemblies
Signing assemblies and the Global Assembly Cache
While every C# program is packaged as an assembly, many of the features of assemblies are designed to make it easy to deliver a special class of programs called components. Understanding components is essential to understanding the benefits of assemblies, so let's review what a component is.