IL Disassembler

One of the many handy tools that ships with Visual Studio is the IL Disassembler (ildasm.exe). It can be used to navigate the metadata within a module, including the types the module exposes, as well as their properties and methods. The IL Disassembler can also be used to display the IL contained within a module.

You can find the IL Disassembler in the SDK installation directory for Visual Studio 2012; the default path is C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools. Note there is a 64-bit version in a sub folder of this location. When you start the application a window similar to the one shown in Figure 2.3 will be displayed.

Figure 2.3 ILDasm window

2.3

Within this window, select File ⇒ Open. Open mscorlib.dll, which should be located in your system directory with a default path of C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll.

Once mscorlib.dll has been loaded, ILDasm will display a set of folders for each namespace in this assembly. Expand the System namespace, then the ValueType namespace, and finally double-click the Equals method.

Figure 2.4 IL code for method Equals

2.4

Figure 2.4 shows the IL for the Equals method. Notice how the Reflection API is used to navigate through the instance of the value type's fields in order ...

Get Professional Visual Basic 2012 and .NET 4.5 Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.