The ilasm.exe tool is used to generate a Portable Executable
(PE) file from Microsoft Intermediate Language (MSIL). So we can run the PE
file and check whether the MSIL code runs as expected.
The syntax of using ilasm.exe tool is:
ilasm [options] nameofthefile [[options] nameofthefile...]
The nameofthefile is the .il source file which consists of
MSIL instructions.
Here are some important options which can be used with the
tool.
Option
|
Description
|
/dll
|
Produces the .dll file as an output.
|
/exe
|
Produces the .exe file as an output.
|
/fold
|
This option is used to fold the identical method bodies
into one. This is a new option available in .Net framework 2.0
|
/include=filepath
|
This is used to set the path for including the file using
#include.
|
/key=filename
|
Complies the file with strong signature using the key
specified in the given file name.
|
/mdv=versionstring
|
This option is used to set the meta data version. This
option is new in .Net framework 2.0.
|
/output:file.extenstion
|
This option is used to specify the output filename and
extension. The default extension is .exe.
|
/optimize
|
Optimize the long instructions to short; this is new in
.Net Framework 2.0.
|
/resource:file.res
|
Includes the specified resource file in *.res format in
the resulting .exe or .dll file. Only one .res file can be specified with the
/resource option.
|
/?
|
Displays all the available options of the tool.
|
Example 1: Generating a .dll using MSIL file
Ilasm filename /dll
Example 2. Generating a .exe using MSIL file
Ilasm testfilename
Example 3: To generate a .dll with a specific name
ilasm FileName /dll /output:Test.dll