Click here to Skip to main content
Click here to Skip to main content

CLR Versions

, 29 Aug 2012
Rate this:
Please Sign up or sign in to vote.
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:

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

License

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

About the Author

Girish J Jain
Technical Lead MASTEK Ltd
India India
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.
Follow on   Twitter

Comments and Discussions

 
GeneralFramework and CLR are different Pinmemberspvasekar3-May-13 3:50 
GeneralRe: Framework and CLR are different PinmemberGirish J Jain4-May-13 18:11 
GeneralMy vote of 5 PinmemberChristian Amado27-Aug-12 9:19 

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

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

| Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 29 Aug 2012
Article Copyright 2012 by Girish J Jain
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid