What are the `exact` differences between .NET dll and a normal dll?

I’ve copied and pasted this from my own post on it:

The format of a .NET dll is:

  • PE header
  • CLR header
  • CLR metadata
  • CLR IL code
  • Native data

PE header

The PE header is the portable executable header that all Win32 applications and libraries have, and instructs Windows what to do with the file. With .NET assemblies this loads the CLR which in turn loads the assembly.

CLR header

This contains information such as the .NET version the .exe or assembly was written with, any strong name signature hash, the address (RVA or relative virtual address) in the file that the resources can be found. And most importantly the entry point for the application which is a token pointing to the MethodDef metadata table, or another file. This token is 0 for class libraries.

CLR metadata

This is information about the module that is stored inside several different types of “streams”. These streams are typically compressed, with the exception of #~ which can be uncompressed for edit and continue. The streams come in two forms, a heap which is just used for storage, and tables.

The various parts of your DLL/assembly are stored in different tables based on what they do – for example all types are stored in the TypeRef table, all methods in the Method table. Each of the tables references a parent table.

The start point of the tables is the Module table which contains just the name and guid of the module as a single row. After this is the ModuleRef table which contains information about all modules that are referenced by this module (from the same assembly). In the case of VS.NET and its use of csc.exe there aren’t multiple files in the assembly, just one module.

After this is the TypeDef table which contains 6 columns holding the type’s name, namespace, its parent (0 for interfaces and Object), the start row for its fields in the FieldDef table, start row for its methods in the MethodDef table.

IL and native data

The app itself.

The book Inside Microsoft .NET IL Assembler – Serge Lidin goes into a lot more detail if you’re interested.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)