CHAPTER 1 THE PHILOSOPHY OF .NET
Note There is one point to be made regarding the abbreviation “IL.” IL is also known as Microsoft Intermediate
Language (MSIL) or alternatively as the Common Intermediate Language (CIL). Thus, as you read the .NET
literature, understand that IL, MSIL, and CIL are all describing the same concept. In this text, I will use the
abbreviation CIL to refer to this low-level instruction set.
When a *.dll or *.exe has been created using a .NET-aware compiler, the binary blob is termed an
assembly. You will examine numerous details of .NET assemblies in Chapter 14. However, to facilitate
the current discussion, you do need to understand some basic properties of this new file format.
As mentioned, an assembly contains CIL code, which is conceptually similar to Java bytecode in that
it is not compiled to platform-specific instructions until absolutely necessary. Typically, “absolutely
necessary” is the point at which a block of CIL instructions (such as a method implementation) is
referenced for use by the .NET runtime.
In addition to CIL instructions, assemblies also contain metadata that describes in vivid detail the
characteristics of every “type” within the binary. For example, if you have a class named SportsCar, the
type metadata describes details such as SportsCar’s base class, which interfaces are implemented by
SportsCar (if any), as well as a full description of each member supported by the SportsCar type. .NET
metadata is always present within an assembly, and is automatically generated by a .NET-aware
language compiler.
Finally, in addition to CIL and type metadata, assemblies themselves are also described using
metadata, which is officially termed a manifest. The manifest contains information about the current
version of the assembly, culture information (used for localizing string and image resources), and a list
of all externally referenced assemblies that are required for proper execution. You’ll examine various
tools that can be used to examine an assembly’s types, metadata, and manifest information over the
course of the next few chapters.
The Role of the Common Intermediate Language
Let’s examine CIL code, type metadata, and the assembly manifest in a bit more detail. CIL is a language
that sits above any particular platform-specific instruction set. For example, the following C# code
models a trivial calculator. Don’t concern yourself with the exact syntax for now, but do notice the
format of the Add() method in the Calc class.
// Calc.cs
using System;
namespace CalculatorExample
{
// This class contains the app's entry point.
class Program
{
static void Main()
{
Calc c = new Calc();
int ans = c.Add(10, 84);
Console.WriteLine("10 + 84 is {0}.", ans);
10