You can install and run multiple versions of the .NET Framework on a computer and each version can be installed in any order. Starting from Windows XP, the operating system comes with a .NET Framework version installed and ready for use; the user can install a more recent version to get all the advantages that comes with the newest class libraries and namespaces provided by the most recent versions of the .NET Framework.
Each .NET Framework version can be installed side-by-side and each version's files will be installed into a subfolder of the Windows main directory, identified by the environment variable %WINDIR%. To see which versions are installed, look into the %WINDIR% directory for the Microsoft.NET\Framework folder (you should also view the Framework64 directory if you're running a 64-bit operating system, which can have 32 or 64-bit versions installed or both): each version of the .NET Framework has a directory and the first two digits of the directory name identify the .NET Framework version; for example: v1.1.4322 for the .NET Framework 1.1, v2.0.50727 for the .NET Framework 2.0, v3.5 for the .NET Framework 3.5 and so on. Figure 1 depicts the folders containing the files for multiple .NET Framework version installed on a computer running Windows 7 Ultimate x64 Service Pack 1.
Figure 1: .NET Framework version specific subfolders.
The informations related to the .NET Framework installation (along with the informations regarding the status of the installed Service Packs) are stored in the Windows registry under the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP key. Figure 2 depicts the registry keys for multiple .NET Framework version installed on a computer running Windows 7 Ultimate x64 Service Pack 1.
Figure 2: .NET Framework version specific registry keys.
Table 1 provides a list of the stored values according to each installed .NET Framework version.
Table 1: .NET Framework version specific registry keys values.
To detect the existence of a specific .NET Framework version regardless of the Service Pack level, or to detect a service pack level or a later service pack level of the same .NET Framework version, use the registry information that listed Table 2.
Table 2: .NET Framework version specific registry keys values regardless of the Service Pack level.
The .NET Framework version can be determined by writing code that queries the Common Language Runtime (CLR) version by using the Version property of the System.Environment class, as in the following C# code snippet
using System; class Sample { public static void Main() { Console.WriteLine(); Console.WriteLine("Version: {0}", Environment.Version.ToString()); } }
If you compile this program with the .NET Framework 3.5, this property's value will be "2.0.50727.3603".
The CLR Version tool (Clrver.exe) reports all the installed versions of the Common Language Runtime (CLR) on the computer. This tool is automatically installed with Visual Studio and with the Windows SDK and it must be executed from the Visual Studio Command Prompt or the Windows SDK Command Prompt. At the command prompt type the following
clrver [option]
where [option] can be -all to display all the managed processes and the version of the CLR they are using, -? to display command syntax and options for the tool or pid to display the version(s) of the CLR used by the process that has the specified process ID. Running the tool with no options displays all installed CLR versions.
This article is also available in the following languages:
Luigi Bruno edited Revision 10. Comment: Edited the "Registry Keys" section.
Luigi Bruno edited Revision 8. Comment: Edited the "Registry Keys" section.
Luigi Bruno edited Revision 7. Comment: Edited the "Registry Keys" section.
Luigi Bruno edited Revision 6. Comment: Edited the "Registry Keys" section.
Luigi Bruno edited Revision 5. Comment: Edited the "Registry Keys" section.
Luigi Bruno edited Revision 4. Comment: Edited the "Registry Keys" section.
Luigi Bruno edited Revision 3. Comment: Edited the "Registry Keys" section.
Luigi Bruno edited Revision 2. Comment: Edited the "The Registry Keys" section.
Luigi Bruno edited Revision 1. Comment: Filled in the "The Registry Keys" section.
Luigi Bruno edited Original. Comment: Filled in the "The CLRVER Tool" section.
Nice article