Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / CLR

CLR Versions Compatibility

3.25/5 (4 votes)
29 Aug 2012CPOL2 min read 13.5K  
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)