Assembling Intermediate Language Source Code

This section provides a tutorial example on how to use the .NET Intermediate Language assembler to assemble IL source code into bytecode and stored in a PE file.

The next thing we want to know is how to compile an IL (Intermediate Language) source code to bytecode. To do this we need to use the .NET IL Assembler located at "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ilasm.exe".

1. Open a command window and run "ilasm.exe" with "":


Microsoft (R) .NET Framework IL Assembler.  Version 2.0.50727.3053
Copyright (c) Microsoft Corporation.  All rights reserved.
Assembling ''  to EXE --> 'HelloCLR_dis.exe'
Source file is UTF-8

Assembled method HelloCLR::Main
Assembled method HelloCLR::.ctor
Creating PE file

Emitting classes:
Class 1:        HelloCLR

Emitting fields and methods:
Class 1 Methods: 2;

Emitting events and properties:
Class 1
Writing PE file
Operation completed successfully

2. Run the new CLR based PE file "HelloCLR_dis.exe" generated by the .NET IL Assembler:

Hello CLR 2.0.50727.3615!

Congratulations. We have successfully assembled an Intermediate Language source code to a bytecode and executed with .NET CLR 2.0!

Table of Contents

 About This Book

 Introduction of C# (C Sharp)

 Data Type and Variables

 Logical Expressions and Conditional Statements

 Arrays and Loop Statements

 Data Type Features

 Floating-Point Data Types

 Passing Parameters to Methods

 Execution Environment Class

 Visual C# 2010 Express Edition

 Class Features

C# Compiler and Intermediate Language

 Compiling and Running C# Programs

 Compilation - Converting Source Code to Bytecode

 .NET Intermediate Language Disassembler

 CLR Based PE (Portable Executable) Files

 Disassembling Intermediate Language Bytecode

Assembling Intermediate Language Source Code

 Compiling C# Source Code Files

 MSBuild - Microsoft Build Engine

 Memory Usages of Processes

 Multithreading in C#

 Async Feature from C# 5

 System.IO.FileInfo Class

 System.Diagnostics.FileVersionInfo Class

 WPF - Windows Presentation Foundation

 Partial Classes and Partial Methods

 Outdated Tutorials


 Full Version in PDF/ePUB