Sunday, October 28, 2007

Detecting what .Net CF version is installed on your device

Are you looking for help detecting what .Net CF version is installed on your device? Do you need to find out if it’s already installed or not? I’ll try to give you some help in both topics.

For the end-user, the easiest way to find the .Net CF version installed on Windows Mobile prior to WM6, is using the “Remove programs” option in the device “Settings” menu. In the list of software installed on your device you can find the .Net CF including the version. If you cannot find the Microsoft .Net Compact Framework there, it’s not installed on your device. Please be careful and do NOT uninstall .Net CF accidentally.
Some devices (i.e. Windows Mobile 6 devices) have .Net CF included on ROM (out of the box). On those devices the previous method cannot help. The best end-user method to detect the .Net CF version on your device is using “cgacutil.exe”. You can find this app using a file explorer in the “\Windows” folder on your device. Running “cgacutil.exe” you’ll see the .Net CF versions installed on your device (i.e. a message showing [3.5.7121.0, 2.0.7045.0] means your device have .Net CF 3.5 Beta 2 and 2.0 SP2). If you cannot find “cgautil.exe” on your device, .Net CF is not installed.

If you’re a developer, probably you’ll need a way to programmatically detect if .Net CF is installed and/or what version is installed on the device. To check if .Net CF is installed, you can use kind of a native code installer, and look on the device registry for the following Key:

[HKEY_LOCAL_MACHINE\Software\Microsoft\.NETCompactFramework]

You’ll find a dword value for each .Net CF version installed on your device with the version as the name (i.e. two dword values named “3.5.7121.0” and “2.0.7045.0”). The value can be “1” or “0”. A “1” value means the version is installed on ROM and a “0” value means it has been installed manually and can be uninstalled. If you cannot find the registry key or any value in there, the .Net CF is not installed on the device.
Finally, from your .Net CF application you can detect the current version using:

Environment.Version

In a device with several .Net CF versions installed, you can also configure your application to run on a specific version. Take a look at this article to learn a little bit more about it.

What about friendly version names? Here you have a list of .Net CF versions:

  • 1.0.2268.0: 1.0 RTM
  • 1.0.3111.0: 1.0 SP1
  • 1.0.3226.0: 1.0 SP2 (Recalled)
  • 1.0.3227.0: 1.0 SP2 Beta
  • 1.0.3316.0: 1.0 SP2 RTM
  • 1.0.4177.0: 1.0 SP3 Beta
  • 1.0.4292.0: 1.0 SP3 RTM
  • 2.0.4037.0: 2.0 May CTP
  • 2.0.4135.0: 2.0 Beta 1
  • 2.0.4317.0: 2.0 November CTP
  • 2.0.4278.0: 2.0 December CTP
  • 2.0.5056.0: 2.0 Beta 2
  • 2.0.5238.0: 2.0 RTM
  • 2.0.6103.0: 2.0 SP1 Beta
  • 2.0.6129.0: 2.0 SP1 RTM
  • 2.0.7045.0: 2.0 SP2 RTM
  • 3.5.7066.0: 3.5 Beta 1
  • 3.5.7121.0: 3.5 Beta 2

6 comments:

Anonymous said...

Incredibly helpful! I was able to find the exact version I have on my wm6 device in the registry without problems.

Sravan said...

thx a lot :)

Anonymous said...

If a version of the CF is pre-installed by the manufacturer it may not show up in Add/Remove Programs - so this is a great tip.

Thanks!

Dejan said...

I have a huge problem.
3 days ago I've got a message SMSlauncher.exe is missing some components... after some research I found that I have to reinstall CF.35 but I couldn't. Iget t the error that cf 3.5 is already installed...
cgautil.exe is showing that cf3.5 is still installed but there is no value for 3.5 in HKEY_LOCAL_MACHINE\Software\Microsoft\.NETCompactF ramew...
also netcfcfg.cab is showing that 3.5 in NOT installed.

I've already spent 3 days installing and uninstalling and I would prefer not to have to do hard reset if possible ....
Can you please help?
Thank you!

Anonymous said...

The wonders of the internet are not because of the internet itself... its people like you that make it worth! thanks for your advice.

Ghostspook said...

Muchas gracias, José. Realment útil tu blog. Un saludo desde Ecuador.