Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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

  1. Open Windows Explorer and navigate to the CP subdirectory under the CLRVerSample directory.

  2. Double-click the icon for CLRVerCP.sln to open it in Visual Studio 2005.

  3. On the Build menu, click Build Solution.

To run the sample

  1. In the Command Prompt window, navigate to the directory that contains the new executable.

  2. 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 Windows Software Development Kit (SDK) installation directory, to list the versions of the CLR that are installed on the local computer.

This sample calls the unmanaged GetRequestedRuntimeInfo Function method, 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 the GetRequestedRuntimeInfo Function parameters:

  • The first three parameters as null.

  • The RUNTIME_INFO_UPGRADE_VERSION flag in the RUNTIME_INFO_FLAGS Enumeration enumerations specified for the runtimeInfoFlags parameter.

The GetRequestedRuntimeInfo Function method 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.

  • If CorBindToRuntimeEx Function was called specifying an earlier CLR version.

  • If an application is currently running that was compiled for an earlier CLR version.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft