Click here to Skip to main content
15,887,434 members
Articles / CLR

CLR Versions

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
29 Aug 2012CPOL3 min read 22.5K   7   3
Lets learn different CLR versions which exist and did we miss one between v2.0 and v4.0?

Today, I want to talk about different CLR versions which exist and our understanding about them. Let’s build a small application and build it against different versions of .Net framework. We will use vanilla source code to output "Hello World" and the underlying (CLR) framework version used.

Source Code:

C#
using System;

public class HelloApp
{
    static public void Main()
    {
        Console.WriteLine("Hello World!!");
        Console.WriteLine();
        Console.WriteLine(string.Format("Framework version used : {0}", Environment.Version));

        Console.ReadLine();
    }
}

Let’s build the application against different versions of .Net Framework (using Visual Studio).

In order to compile the application you need to open Visual Studio 20XX Command Prompt and use the following command:

csc HelloApp.cs 

It will generate HelloApp.exe and you can check the metadata of the generated assembly by using following command:

ildasm HelloApp.exe

Now let’s check output of the above program with respect to different versions of .Net Framework and the metadata changes.

 

Visual Studio 2003 (.Net Framework 1.1)

Compiling the application and executing it from VS 2003 command prompt produces the following output:

VS2003 CLR 1.1 Execution

As we can see, (and as expected) it is targeting CLR v1.1. Let’s check the metadata of the generated assembly:

CLR 1.1 Assembly Metadata

It shows the Metadata version and the version of mscorlib being targeted. We can see it is targeting CLR v1.1, which is what one would expect.

 

Visual Studio 2005 (.Net Framework 2.0)

Compiling the application and executing it from VS 2005 command prompt produces the following output:

VS2005 CLR 2.0 Execution

As we can see, (and as expected) it is targeting CLR v2.0. Let’s check the metadata of the generated assembly:

CLR 2.0 Assembly Metadata

We can see it is targeting CLR v2.0, which is what one would expect.

Visual Studio 2008 (.Net Framework 3.0/3.5)

Compiling the application and executing it from VS 2008 command prompt produces the following output:

VS2008 CLR 2.0 Execution

Surprise!! It is targeting CLR v2.0, something which I did not expect. Let’s check the metadata of the generated assembly:

CLR 2.0 Assembly Metadata for VS2008

We can see it is targeting CLR v2.0, which confirms the reason for the above output. Why would an application compiled using Visual Studio 2008 (which was using .Net Framework 3.5) target .Net Framework 2.0? Before answering this question, let’s see the output with Visual Studio 2010.

Visual Studio 2010 (.Net Framework 4.0)

Compiling the application and executing it from VS 2010 command prompt produces the following output:

As we can see, (and as expected) it is targeting CLR v4.0. Let’s check the metadata of the generated assembly:

We can see it is targeting CLR v4.0, which is what one would expect.

So, we saw the application targeting CLR v1.1, 2.0, and v4.0 but, where did CLR v3.0/3.5 go? In fact, CLR v3.0/v3.5 never existed. In reality, .Net Framework 3.0 release contained additional set of libraries such as WCF, WF, and WPF which were all built upon existing CLR v2.0. The underlying CLR was not changed at all as part of .Net Framework v3.0 release. None of the core libraries were changed and hence the CLR version remained same. CLR version has now changed with .Net Framework v4.0 release as there are substantial changes to Base Class Library (BCL) in CLR v4.0. Basically, CLR skipped version from v2.0 to v4.0. There was no CLR v3.0 or v3.5.

In my next post, we will see applications compatibility between CLR versions i.e. how applications targeting a particular version of CLR work with another version (i.e. forward and backward compatibility)

Vande Mataram!

(A salute to motherland)

P.S. In addition to blogging, I use Twitter to share tips, links, etc. My Twitter handle is: @girishjjain

This article was originally posted at http://girishjjain.com/blog/post/CLR-Versions.aspx

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead CitiusTech
United States United States
Girish Jain works on Microsoft .Net framework technologies and is a big fan of WPF, WCF, and LINQ technologies. When not spending time with family, Girish enjoys creating small tools, utilities, frameworks to improve developer productivity and also writes Windows Phone applications.

Loves economics, technology, family, and tennis. Pity liars and politicians.

Comments and Discussions

 
GeneralFramework and CLR are different Pin
spvasekar3-May-13 3:50
spvasekar3-May-13 3:50 
GeneralRe: Framework and CLR are different Pin
Girish J Jain4-May-13 18:11
Girish J Jain4-May-13 18:11 
GeneralMy vote of 5 Pin
Christian Amado27-Aug-12 9:19
professionalChristian Amado27-Aug-12 9:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.