Viewing 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 view assembly contents
At the command prompt, type the following command:
ildasm <assembly name>
In this command, assembly name is the name of the assembly to examine.
The following example opens the Hello.exe
assembly.
ildasm Hello.exe
To view assembly manifest information, double-click the manifest icon in the MSIL Disassembler window.
Hello, World Example
The following example shows a basic "Hello, World" program.
Imports System
Public Module modmain
Sub Main()
Console.WriteLine ("Hello World using Visual Basic!")
End Sub
End Module
[C#]
using System;
class MainApp {
public static void Main() {
Console.WriteLine("Hello World using C#!");
}
}
[C++]
#using <mscorlib.dll>
using namespace System;
void main() {
Console::WriteLine(L"Hello World using Managed Extensions!");
}
Using Ildasm.exe, you can view the following information in the assembly manifest:
.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
Assembly Manifest Directives
The following table describes each directive in the assembly manifest of the Hello, World 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 for metadata located in the .NET Framework SDK in the Tool Developer's Guide directory.
See Also
Creating Assemblies | MSIL Disassembler (Ildasm.exe) | Programming with Assemblies