Jump to content

Microsoft Intermediate Language

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 128.49.49.178 (talk) at 18:47, 31 August 2005. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

During compilation, .NET code is translated into Microsoft Intermediate Language (MSIL) rather than machine-specific binary code. MSIL is a machine- and platform-independent instruction set that can be executed in any environment within the .NET framework. .NET uses just-in-time (JIT) compilation as its primary means of executing MSIL. You can generate native binary images using Microsoft’s Native Image Generator (NGEN).

Just-In-Time (JIT) Compilation

This is the primary method by which .NET executes MSIL. As the MSIL is executed, the code is compiled and optimized for the executing environment. JIT compilation provides environment optimization, runtime type safety, and assembly verification. To accomplish this, the JIT compiler examines the assembly metadata for any illegal accesses and handles violations appropriately.

NGEN (Native Image Generator) Compilation

NGEN enables you to produce a native binary image of MSIL code for the current environment. This improves the performance of the .NET application by eliminating the JIT overhead associated with the execution. Once you run NGEN against an assembly, the resulting native image is placed in the Global Assembly Cache for use by all other .NET assemblies.
NGEN is a good tool for improving performance of .NET applications as long as the executing environment remains static. If you execute an NGEN-generated image in an incompatible environment, .NET automatically reverts to using JIT. To mitigate this, run NGEN during deployment against the installed assemblies.

Compiling .NET code produces two things:

Microsoft Intermediate Language (MSIL)
An intermediate instruction set into which all .NET languages compile. You can execute MSIL code on any environment that supports the .NET framework. MSIL-compiled code is verified for safety during runtime, providing better security and reliability than natively compiled binaries.
Metadata
Information about the MSIL-compiled classes. Metadata in .NET serves the same purpose as a COM-type library. Metadata enables applications to support and discover the interfaces of classes in the assembly. The process of reading metadata is reflection. Metadata shows developers the methods and other information for particular classes. To view an assembly’s metadata, use the Intermediate Language Disassembler (ILDASM).

File:Dotnetframework.jpg