The MSIL and metadata of it are contained in a portable
executable (PE) file. The term "PE" implies "Portable Executable,"
which came into being with the intent of having a common file format for all
flavors of Windows Operating Systems on all supported CPU's. This is based on
and the Common Object File Format (COFF). This file format, which accommodates
MSIL or native code as well as metadata, enables the operating system to
recognize common language runtime images. The presence of metadata in the file
along with the MSIL makes the code self-describing, therefore, eliminating the
need for type libraries or Interface Definition Language (IDL). At runtime, the
metadata is read as and when it is needed for execution.
When a program targeted at the CLR is compiled, it generates
MSIL code which is in turn stored in a Portable Executable (PE) format. The
Portable Executable (PE) format (based on COFF) specifies a portable file
format for executables, object code, and DLLs that are used in Windows operating
systems. In order to make them portable across all 32-bit and 64 - bit Windows
Operating Systems, all .NET assemblies are actually portable executable or PE
files. The code, metadata and resources of the MSIL are actually stored in a
data section in the PE file. The following is the layout of a PE file (also
known as an Image file) in the COFF format.
Listing 3: The PE File Structure