Click here to Skip to main content
15,886,720 members
Articles / CLR

CLR Versions Compatibility

Rate me:
Please Sign up or sign in to vote.
3.25/5 (4 votes)
29 Aug 2012CPOL2 min read 12.9K   4   7
Let's learn the compatibility between multiple CLR versions which exist and how we can use the supportedRuntime element in an application's configuration file.

Let us try to execute application built against one version of CLR on another CLR version, to understand forward and backward compatibility of CLR versions.

You can control the CLR version to be used for executing your application using application configuration file and supportedRuntime element, as follows:

Image 1

Forward Compatibility (v1.1 to v2.0)

Let’s modify the application configuration file for CLR v1.1 application and try to execute it on CLR v2.0 and check the output.

Configuration changes:

Image 2

Now executing the application produces the following:

Image 3

As can be seen, CLR 1.1 applications are forward-compatible with CLR v2.0*.

Forward Compatibility (v2.0 to v4.0)

Let’s modify the application configuration file for CLR v2.0 application and try to execute it on CLR v4.0 and check the output.

Configuration changes:

Image 4

Now executing the application produces the following:

Image 5

As can be seen, CLR 2.0 applications are forward-compatible with CLR v4.0*.

Forward Compatibility (v1.1 to v4.0)

Let’s modify the application configuration file for application CLR v1.1 application and try to execute it on CLR v4.0 and check the output.

Configuration changes (basically same as we did in the last step):

Image 6

Now executing the application produces the following:

Image 7

As can be seen, CLR 1.1 applications are forward-compatible with CLR v4.0*.

Backward Compatibility (v2.0 to v1.1)

Executing CLR v2.0 application on CLR v1.1 produces the following errors:

First, the following message appears:

Clicking on Ok button shows the following:

Image 8

And then the following exception in the command prompt:

Image 9

Hence, CLR v2.0 applications are NOT backward compatible with CLR v1.1.

Backward Compatibility (v4.0 to v2.0)

Similarly, while executing CLR v4.0 application on CLR v2.0, we get the following exceptions:

Image 10

Image 11

Hence, CLR v4.0 applications are NOT backward compatible with CLR v2.0.

To summarize forward/backward compatibility of CLR versions:

  1. CLR v1.1 apps are forward compatible with CLR v2.0*
  2. CLR v1.1 apps are forward compatible with CLR v4.0*
  3. CLR v2.0 apps are forward compatible with CLR v4.0*
  4. CLR v2.0 and v4.0 apps are NOT backward compatible, i.e., app built against a version of CLR, cannot run on the older version of CLR (it throws BadImageFormatException)

[*]When we talk about forward compatibility, it is important to note that the newer version of CLR would have introduced some breaking changes by modifying base class library and hence, to determine whether your application is fully compatible, you need to actually test your application on the newer CLR version before concluding on the 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)


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

 
GeneralMy vote of 1 Pin
Mr.Daviess31-Mar-15 7:09
Mr.Daviess31-Mar-15 7:09 
GeneralMy vote of 3 Pin
Klaus Luedenscheidt27-Aug-12 17:43
Klaus Luedenscheidt27-Aug-12 17:43 
GeneralRe: My vote of 3 Pin
Girish J Jain28-Aug-12 23:25
Girish J Jain28-Aug-12 23:25 
GeneralRe: My vote of 3 Pin
Richard Deeming5-Sep-12 8:09
mveRichard Deeming5-Sep-12 8:09 
GeneralRe: My vote of 3 Pin
Girish J Jain8-Sep-12 3:21
Girish J Jain8-Sep-12 3:21 
GeneralMy vote of 5 Pin
Christian Amado27-Aug-12 9:18
professionalChristian Amado27-Aug-12 9:18 
GeneralRe: My vote of 5 Pin
Girish J Jain28-Aug-12 23:21
Girish J Jain28-Aug-12 23:21 

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.