Determine which version of the .NET Compact Framework is in use

Yesterday I outlined how an end user can determine which version(s) of the .NET Compact Framework are installed on a device. Sometimes it can be useful to query which specific version of the framework an application is currently running on. This could be used for instance, in automated bug report forms to provide your support staff with an accurate picture of the environment your application is being utilised within.

Within an application you can simply query the Envrionment.Version property to determine the version of the CLR your application is running on, for example:

MessageBox.Show(Envrionment.Version.ToString(), "CLR Version Number");

The version property is an instance of the System.Version class. To check if your application is running on a specific version of the .NET Compact Framework you can construct an instance of the Version class to represent the desired version number (see yesterday’s entry for a table) and perform a simple comparision, as the following example demonstrates:

Version targetVersion = new Version("2.0.7045.0");
if (Envrionment.Version == targetVersion)
     MessageBox.Show("You are running .NET CF 2.0 SP1", "Status");

One Response to “Determine which version of the .NET Compact Framework is in use”

  1. I just came across Neil Cowburn’s posting on HOWTO: Determining the .NET Compact Framework Version. The article contains a much more complete table of possible framework version numbers to .NET Compact Framework release mappings. Well worth a look for anyone considering using this technique.

Leave a Reply