ILDASM

I l @ ve RuBoard

The .NET ships with several tools, ranging from compilers to form designers. However, the most important tool is ILDASM, Intermediate Language Disassembler. ILDASM allows for peeking into various .NET assemblies. Regardless of the language used to implement the assembly, ILDASM is capable of displaying the resulting IL.

The main window of ILDASM creates a treeview detailing the contents of a .NET assembly. The treeview is grouped by namespace with each namespace containing one or more nested namespaces, structs, classes, interfaces, or enumerations (see Figure 1.3.4).

Figure 1.3.4. ILDASM with mscorlib.dll loaded.

graphics/0103fig04.gif

Locate the .NET assembly mscorlib.dll and use ILDASM to view the contents. Depending on the install of the .NET SDK, the .NET assemblies should be located in <rootdrive>:\< windows directory>\Microsoft.Net\Framework\vN.N.NNN .

Make the appropriate substitutions. Figure 1.3.5 shows the various symbols and their meanings for ILDASM.

Figure 1.3.5. ILDASM symbol table.

graphics/0103fig05.gif

At the heart of the .NET framework is the mscorlib.dll assembly. This assembly contains most of the standard classes and interfaces that comprise .NET. Certainly there are other assemblies for database access, networking, security and such, but at the root of it all is mscorlib.dll .

Using the symbol table in Figure 1.3.5, you can visually determine entity types found within mscorlib.dll . Locate System.Object and double-click the node to expand it (see Figure 1.3.6).

Figure 1.3.6. System.Object in ILDASM.

graphics/0103fig06.gif

The System.Object class is the base class of all .NET classes. The System.Object base class provides shared functionality used throughout .NET. Locate the ToString method and double-click it to view the underlying IL code that comprises it (see Figure 1.3.7).

Figure 1.3.7. IL code for System.Object.ToString() .

graphics/0103fig07.gif

MFC developers were accustomed to having the Visual C++ source code to the MFC framework readily available for their inspection. This is not the case with the .NET framework. Currently, the only way to get a peek under the covers is to use a tool such as ILDASM to view the IL implementation. Although IL is not as easy to read as, say, C# or VB.NET, it will allow for an understanding of the internal workings of the .NET classes none the less.

ILDASM provides the ability to produce a text file with the complete IL source for a given .NET assembly. Launching ILDASM from the command line and using the /OUT=<filename> parameter, ILDASM will direct the disassembly output to the specified file rather than displaying the ILDASM GUI.

I l @ ve RuBoard


C# and the .NET Framework. The C++ Perspective
C# and the .NET Framework
ISBN: 067232153X
EAN: 2147483647
Year: 2001
Pages: 204

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net