MSIL - Microsoft Intermediate Language

Microsoft Intermediate Language

Microsoft Intermediate Language (MSIL) is also knows as Intermediate Language (IL) or Common Intermediate Language (CIL). When an application (or component) written in .NET programming language (like C#, VB.NET, etc.) is compiled, platform independent binaries called assemblies are generated. Generation of platform independent binaries results in same code base running on multiple operating systems. Assemblies contain metadata, Intermediate Language instructions, manifest and any resources. MSIL is similar to Java Byte code.

Intermediate Language emitted by.NET aware compilers is almost identical. During runtime the JIT (Just in time compiler) provided by the CLR (Common Language Runtime) converts the IL instructions into platform specific instructions. Each platform support by the .NET framework comes with its own version of JIT, which emits instructions for target CPU.

The advantage of Intermediate language is it is same for all the .NET aware languages and it is platform independent, programmer doesn’t have to release different versions of the application for each supported platform. Microsoft.NET application can be written purely using IL and can be compiled using ilasm.exe (Intermediate Language Assembler) tool, which is installed with Visual Studio. Application developer, developing applications using high level language like C# does not need to be aware of IL programming. However, it’s good to have basic knowledge in IL instruction set so that programmer can use tools like Ildasm.exe (Intermediate Language Dissembler) to analyze third party .NET components.

Since all .NET aware languages emit same Intermediate language instructions, components written in one .NET aware language can be easily consumed in application written in another .NET aware language. Cross language inheritance is also supported in .NET, a class can derive from a base class written in another .NET aware language.

 .NET code written using one language can be decompiled into another language using decompilers like .NET reflector and Telerik Just Decompile. Let’s say you have an application developed in VB.NET and for some reason you want to port this application to C#, you can use the help of a decompiler to decompile the application to C#. The decompiled code may not be a readily working code, programmer has to make some changes to recompile using target compiler.