Udostępnij za pośrednictwem


How to: View Assembly Contents

You can use the MSIL Disassembler (Ildasm.exe) to view Microsoft intermediate language (MSIL) information in a file. If the file being examined is an assembly, this information can include the assembly's attributes, as well as references to other modules and assemblies. This information can be helpful in determining whether a file is an assembly or part of an assembly, and whether the file has references to other modules or assemblies.

To display the contents of an assembly using Ildasm.exe

  • Type ildasm <assembly name> at the command prompt. For example, the following command disassembles the Hello.exe assembly.

    ildasm Hello.exe
    

To view assembly manifest information

  • Double-click the MANIFEST icon in the MSIL Disassembler window.

Example

The following example starts with a basic "Hello, World" program. After compiling the program, use Ildasm.exe to disassemble the Hello.exe assembly and view the assembly manifest.

Imports System
Public Module modmain
   Sub Main()
      Console.WriteLine ("Hello World using Visual Basic!")
   End Sub
End Module 
using System;
class MainApp {
     public static void Main() {
        Console.WriteLine("Hello World using C#!"); 
    }
}
#using <mscorlib.dll>
using namespace System;
void main() {
   Console::WriteLine(L"Hello World using Managed Extensions!");  
}

Running the command ildasm.exe on the Hello.exe assembly and double-clicking the MANIFEST icon in the IL DASM window produces the following output:

.assembly extern mscorlib
{
  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )              // .z\V.4..
  .ver 1:0:2411:0
}
.assembly Hello
{
  // --- The following custom attribute is added automatically; do not uncomment. -------
  //  .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(bool,
  //                                                                                bool) = ( 01 00 00 01 00 00 ) 
  .hash algorithm 0x00008004
  .ver 0:0:0:0
}
.module Hello.exe
// MVID: {58AD9DFD-63A6-462A-8AD5-42CBC95AA147}
.subsystem 0x00000003
.file alignment 512
.corflags 0x00000001
// Image base: 0x03330000

The following table describes each directive in the assembly manifest of the Hello.exe assembly used in the example.

Directive

Description

.assembly extern <assembly name>

Specifies another assembly that contains items referenced by the current module (in this example, mscorlib).

.publickeytoken <token>

Specifies the token of the actual key of the referenced assembly.

.ver <version number>

Specifies the version number of the referenced assembly.

.assembly <assembly name>

Specifies the assembly name.

.hash algorithm <int32 value>

Specifies the hash algorithm used.

.ver <version number>

Specifies the version number of the assembly.

.module <file name>

Specifies the name of the modules that make up the assembly. In this example, the assembly consists of only one file.

.subsystem <value>

Specifies the application environment required for the program. In this example, the value 3 indicates that this executable is run from a console.

.corflags

Currently a reserved field in the metadata.

An assembly manifest can contain a number of different directives, depending on the contents of the assembly. For an extensive list of the directives in the assembly manifest, see the ECMA documentation, especially "Partition II: Metadata Definition and Semantics" and "Partition III: CIL Instruction Set". The documentation is available online; see ECMA C# and Common Language Infrastructure Standards on MSDN and Standard ECMA-335 - Common Language Infrastructure (CLI) on the Ecma International Web site.

See Also

Concepts

Application Domains and Assemblies

Application Domains and Assemblies How-to Topics

Reference

MSIL Disassembler (Ildasm.exe)