Site Feed

Thursday, November 04, 2004

NET Assembly Structure – Part II

So... let me get back to defining assembly structure, a bit more in detail. The .NET assembly is based on Windows Portable Executable (PE) and Common Object File Format (COFF). This runtime image (.NET assembly) will be generated by .NET specific language compilers and the execution engine (CLR) will be able to load this image and execute.

This extended PE/COFF format facilitate Windows operating system to distinguish runtime images, recognizes Microsoft Intermediate Language (MSIL) or native code, and accommodates metadata as an integral part of the emitted code.

The runtime image includes the following sectors:

Runtime Image File Headers
MS-DOS stub
This stub is used to tell the runtime environment that the module can or cannot be run in MS-DOS mode.
COFF Header
COFF header consists of fields for number identifying target machine (processor type), number of sections, date time stamp the file was created, etc.
PE Header
This would contain standard fields identifying the state of image file, linker versions, code size, etc, Windows OS version specific fields such as OS versions, file checksum, size of stack to reserve, size of heap reserve, and Data directories (for use of OS).
Runtime Header
This header contains all of the runtime-specific data entries and other information such as runtime versions required, location and size of meta data in the image, location of CLR resources, strong name signature, etc, remember the term metadata?

MSIL Code or Native Code

Entry Points
Runtime API’s
The following API’s are exported from mscoree.dll and are used to bootstrap the runtime:
_CorExeMain: This method is called to start execution of an executable program.
_CorDllMain: This method is called for the entry point of a DLL.
Entry Points for Windows CE (if the runtime image is for compact framework)
Shut Down Requirements

Resources
This includes any resources such as image files, or those files associated with globalization.

And that makes up a .net assembly !