CLR Version Detection Technology Sample
This sample shows how to detect which versions of the .NET Framework common language runtime (CLR) are installed on a computer.
For information about using the samples, see the following topics:
To build the sample using Visual Studio
Open Windows Explorer and navigate to the CP subdirectory under the CLRVerSample directory.
Double-click the icon for CLRVerCP.sln to open it in Visual Studio 2005.
On the Build menu, click Build Solution.
To run the sample
In the Command Prompt window, navigate to the directory that contains the new executable.
Type CLRVer.exe at the command line.
.NET Framework Version: 2.0, 1.1
Microsoft Visual Studio 2005
These samples require Windows headers which are available to your project if you build using Microsoft Visual Studio 2005, the Visual Studio 2005 Command Prompt, or if you have the Platform SDK installed and specified in an include path.
This sample is available only in C++. The sample code calls unmanaged APIs that are defined in mscoree.h, which is included in the \include subdirectory under your .NET Framework SDK installation directory, to list the versions of the CLR that are installed on the local computer.
This sample calls the unmanagedmethod, which returns information about the CLR version loaded into the process. This information does not always show the latest CLR version installed on the computer.
In the .NET Framework version 2.0, you can get the latest installed CLR version by specifying the following for theparameters:
The first three parameters as null.
The RUNTIME_INFO_UPGRADE_VERSION flag in the runtimeInfoFlags parameter.enumerations specified for the
Themethod may not return the latest CLR version in the following circumstances:
If an application configuration file exists that specifies loading a particular CLR version. Note that the .NET Framework will use the configuration file even if null is specified for pConfigurationFile parameter.
Ifwas called specifying an earlier CLR version.
If an application is currently running that was compiled for an earlier CLR version.