Chapter 15. Assemblies
One of C#’s strengths is the ease with which your code can use all sorts of external components. All C# programs use the components that make up the .NET Framework class library, but many cast their net wider—GUI application developers often buy control libraries, for example. And it’s also common for software developers to want their own code to be reusable—perhaps you’ve built up a handy library of utilities that you want to use in all the projects in your organization.
Whether you’re producing or consuming components, C# makes it simple to achieve binary reuse—the ability to reuse software in its compiled binary form without needing the source code. In this chapter, we’ll look at the mechanisms that make this possible.
.NET Components: Assemblies
In .NET, an assembly is a single
software component. It is usually either an executable program with a file
extension of .exe, or a library with
a .dll extension. An
assembly can contain compiled code, resources (such as bitmaps or string
tables), and metadata, which is information about
the code such as the names of types and methods, inheritance relationships
between types, whether items are
private, and so on.
In other words, the compiler takes pretty much all the information in the source files that you added to your project in Visual Studio, and “assembles” it into a single result: an assembly.
We use this same name of “assembly” for both executables and libraries, because there’s not much difference ...