Wednesday, May 26, 2010

[Tutorial] Migration to Framework .NET 4.0 & Visual Studio 2010
Part1: Version Compatibility and Simple Migration

The new version of .NET Framework 4.0 was released last month together with Visual Studio 2010. An important question is how to migrate existing applications. This series of articles provides information on how to proceed and what you can expect when doing the migration.

Version Compatibility

In most cases the .NET 4.0 Framework is fully compatible with applications that were developed using past versions of the .NET Framework (1.1, 2.0, 3.0, 3.5).

Version Compatibility assures that an application that was developed using a past version of .NET should also work on a more current version. Moreover, source code that was written using an old version should also compile on the current version.

Simple migration

After installing the new Framework version, the old assemblies do not need to be  recompiled. Instead you may execute old and new assemblies Side-By-Side (SxS). It is now possible to to have different versions of the CLR running in the same application and they can even communicate with each other.

If you need to force the usage of CLR 4.0, you only need to add an application configuration file that contains the version specifications. You do this by specifying one or multiple  <supportedRuntime version="vX.X" /> elements (the first being your preferred version).

The following values are currently possible:

Framework .NET Version

Version String











Example of a configuration file for .NET 4.0:


If you need to migrate a large amount of applications it makes more sense to do the migration on machine level. There is the registry key “OnlyUseLatestCLR” that serves for this purpose.

  • Open a registry editor (example: regedit.exe)
  • Set the value of OnlyUseLatestCLR=dword:00000001
  • For 64 bit systems you also need to set the key within [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NET Framework]

To deactivate la functionality, you only need to reset the value of the key to OnlyUseLatestCLR=dword:00000000.


No comments: