Exploring an Assembly Using ildasm.exe

10/2/2010 3:16:42 PM
If you are beginning to feel a tad overwhelmed at the thought of gaining mastery over every namespace in the .NET platform, just remember that what makes a namespace unique is that it contains types that are somehow semantically related. Therefore, if you have no need for a user interface beyond a simple Console Application, you can forget all about the System.Windows.Forms, System.Windows, and System.Web namespaces (among others). If you are building a painting application, the database namespaces are most likely of little concern. Like any new set of prefabricated code, you learn as you go.

The Intermediate Language Disassembler utility (ildasm.exe), which ships with the .NET Framework 4.0 SDK, allows you to load up any .NET assembly and investigate its contents, including the associated manifest, CIL code, and type metadata. By default, ildasm.exe should be installed under C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin (if you cannot find ildasm.exe in this location, simply search your machine for a file named ildasm.exe).


You can easily run ildasm.exe by opening a Visual Studio 2010 Command Prompt, and type "ildasm" (without the quotes) followed by the Enter key.

Once you run this tool, proceed to the File | Open menu command and navigate to an assembly you wish to explore. By way of illustration, here is the Calc.exeCalc.cs file shown earlier in this chapter (see Figure 1). ildasm.exe presents the structure of an assembly using a familiar tree-view format. assembly generated based on the

Figure 1. ildasm.exe allows you to see the CIL code, manifest, and metadata within a .NET assembly

1. Viewing CIL Code

In addition to showing the namespaces, types, and members contained in a given assembly, ildasm.exe also allows you to view the CIL instructions for a given member. For example, if you were to double-click the Main() method of the Program class, a separate window would display the underlying CIL (see Figure 2).

Figure 2. Viewing the underlying CIL

2. Viewing Type Metadata

If you wish to view the type metadata for the currently loaded assembly, press Ctrl+M. Figure 3 shows the metadata for the Calc.Add() method.

Figure 3. Viewing type metadata via ildasm.exe

3. Viewing Assembly Metadata (aka the Manifest)

Finally, if you are interested in viewing the contents of the assembly's manifest, simply double-click the MANIFEST icon (see Figure 4).

Figure 4. Viewing manifest data via ildasm.exe

To be sure, ildasm.exe has more options than shown here, and I will illustrate additional features of the tool where appropriate in the text.

Top 10
Synology Diskstation DS412+ - Speedy Four-Bay Nas
Mac Mini 2012 Review (Part 3)
Mac Mini 2012 Review (Part 2)
Mac Mini 2012 Review (Part 1)
Nokia Lumia 820 Review (Part 3)
Nokia Lumia 820 Review (Part 2)
Nokia Lumia 820 Review (Part 1)
Audio Research REF-10 Preamp (Part 2)
Audio Research REF-10 Preamp (Part 1)
HP LaserJet Pro 100 - Compact Color Laser MRP
Most View
Bridge Camera – A Complete Buyer's Guide! (Part 2)
Oracle Coherence 3.5 : Planning Your Caches - Backing maps
Sony NEX-F3 Review (Part 2)
SQL Server 2008 : Creating SQL Server Audits Using the GUI
Extra Network Hardware Round-Up (Part 2) - NAS Drives, Media Center Extenders & Games Consoles
Windows Server 2008 : Harnessing the Power and Potential of FIM
iPhone 3D Programming : Blending and Augmented Reality - Blending Extensions and Their Uses
Understanding SharePoint 2010 Extranet Security
Adobe Photoshop : Blending Modes
The Outer RIM (Part 2)
Exchange Server 2010 server roles (part 2)
SharePoint 2010 : Creating and Managing Workflows - Workflows in SharePoint 2010
Windows Server 2003 : Planning a Security Framework
Sharepoint 2007: Edit the Properties of a File or a List Item
DSLR – Your Video’s Best Friend (Part 1)
MacBook Pro - The Ultimate Combination
Active Directory Domain Services 2008 : Link a WMI Filter to a Group Policy Object, Determine a Resultant Set of Policy
The Effect Of IOS And Facebook On Shutterbugs (Part 1)
Buying From Itunes (Part 1) - Music purchases, Video purchases
AMD A10 4600M CPU – The Quad Prowess