Ildasm is one of the most frequently used tool by .NET community. It comes as part of the .net sdk since the very beginning.
The main purpose of this tool is to convert the portable executable (PE) file into readable and compilable MSIL code.
For beginners let me just explain few things :
- MSIL : Microsoft Intermediate Language. When you compile your .net source code it gets converted to MSIL which is a platform independent language. The resultant exe or dll which you get contains the MSIL which gets compiled to native code at runtime.
- PE File : The exe or dll file which you get after compilation of .net source code or MSIL code is called portable executable file which contains MSIL plus metadata about types and external dependencies which make PE an independent,self-describing entity and can be executed by runtime.
Ildasm supports both console and rich UI interface. The rich UI interface is the one most commonly used and is very useful for seeing following contents of an assembly :
- Types in that assembly with full qualified names.
- Methods and signatures available in various types.
- Access modifiers of various types.
- Version of that assembly.
- Detecting if its strong named
- External assemblies to which it references to including their version number.
In console mode Ildasm supports various other advanced options. The output in the console mode can be saved to a file in rtf , text or html format.
The other advanced options supported are :
- /linenum : includes references to original source files
- /source : show original source lines as comments
- /html : produces output in html format.
The unrestricted output file containing MSIL generated by Ildasm can be given as input directly to MSIl Assembler Tool (Ilasm.exe) which will generate PE back again from which MSIL was generated.
Ildasm can also be used to check if the exe or dll file is managed or not. For unmanaged files it displays a message that no valid common language header found.