How can I determine the version of the Compact Framework that is installed on my device?

B. Clay Shannon picture B. Clay Shannon · Apr 28, 2014 · Viewed 9.4k times · Source

It looks like this has a solution to my recent hand-wringing and head-ringing in trying to sort out different versions of CF on various devices so that they will all run my CE/CF app. These writhings can be read about here and here.

That link shows a way to get an app built for an older version of the CF to run on a device which has a newer version installed. But it says:

"To determine the currently installed version On the Pocket PC, use File Explorer to navigate to the \Windows directory and tap the cgacutil file. A message box appears with the version of the .NET Compact Framework installed on the device."

However, Windows Explorer (there is no "File Explorer" on my Motorola 3190 device) shows no "cgacutil" in the Windows folder. The file denizens of the folder go from "ceconfig" to "charset" with no "cg*" between them.

The URL linked to above also says:

"To set an application to run on version 3.5 Determine the version number of the .NET Compact Framework running on the device."

How can I determine that? Once I know, I can supposedly add a file with the following data named [appName].exe.config to the handheld device and all will be rainbow stew/big rock candy mountain:

<configuration>
  <runtime>
      <compatibilityversion major="2" minor="0"/>
  </runtime>  
  <startup>
      <supportedRuntime version="v3.5.7000"/>  // <= what value should this be/what is on my device?
  </startup>
</configuration>

But the "v3.5.7000" should in actuality be what? I need to know how to determine that version value.

In System Properties, I can see some OS info, but not the CF version. For instance, I see:

MS Windows CE Version 6.00

UPDATE

Poking around, I noticed that there is a file on the device named "Microsoft .NET CF 2.0.LOG.TXT"

The filename indicates the CF version installed IS 2.0

So, since the .exe that works on the other device seems to be CF 1, can I use this as the contents of the [appName].exe.config file (content inside the file is more specific as to the version number):

<configuration>
  <runtime>
      <compatibilityversion major="1" minor="0"/>
  </runtime>  
  <startup>
      <supportedRuntime version="v2.0.7045.00"/>  
  </startup>
</configuration>

Will that help?

UPDATE 2

The file "Microsoft .NET CF 2.0.LOG file contains some interesting info:

25/04/2014 16:50:32: Entered Install_Init().
    First Call: Yes
    Previously Installed: No
    Installation folder is: '\Windows'.
25/04/2014 16:50:32: Build 2.0.7045.00 created on Feb 13 2007 at 22:23:41
25/04/2014 16:50:32: Device CPU: 'ARMV4I', 05020000 (84017152)
25/04/2014 16:50:32: MOTOROLA WinCE 6.00
25/04/2014 16:50:32: AKU string : ''
25/04/2014 16:50:32: OEM info   : 'MOTOROLA MC3100R'
25/04/2014 16:50:32: Our trust level is: 2
. . .
25/04/2014 16:50:32: Invoker's command line: '/noui \Windows\NETCFV2.wce5.armv4i.cab'
25/04/2014 16:50:32: Memory status, K --------------------------
25/04/2014 16:50:32:   Load           : 35
25/04/2014 16:50:32:   Physical       : 55616
25/04/2014 16:50:32:   Physical free  : 36440
25/04/2014 16:50:32:   Virtual        : 1048576
25/04/2014 16:50:32:   Virtual free   : 1047936
25/04/2014 16:50:32: Storage status, K -------------------------
25/04/2014 16:50:32:   Available to us: 17020
25/04/2014 16:50:32:   Total storage  : 30080
25/04/2014 16:50:32:   Available total: 17020
25/04/2014 16:50:32: -------------------------------------------
25/04/2014 16:50:32: About to process registry.
25/04/2014 16:50:32: Opened CF registry key OK. 
25/04/2014 16:50:32: Looking for upgradeable installations for version '2.0.7045.00'
25/04/2014 16:50:32: Got version value '3.5.7338.00'
25/04/2014 16:50:32: Side by side version '3.5.7338.00' found and skipped.
25/04/2014 16:50:32: Added new CF version value '2.0.7045.00'.
25/04/2014 16:50:32: CF registry key closed.
25/04/2014 16:50:36: Entered Install_Exit().
    Failed Dirs: 0
    Failed Files: 0
    Failed RegKeys: 0
    Failed RegVals: 0
    Failed Shortcuts: 0
. . .
25/04/2014 16:50:36: Processing alternative file: '\Windows\.NET CF 2.0\cgacutil.exe.-500~-500~ARMV4I'.
25/04/2014 16:50:36: Special file extension: '.-500~-500~ARMV4I'.
25/04/2014 16:50:36: File is intended for OS: -500 to -500, CPU: ARMV4I
25/04/2014 16:50:36: Device CPU: 'ARMV4I', 05020000 (84017152)
25/04/2014 16:50:36: CPU matches.
25/04/2014 16:50:36: Version MIN ignored.
25/04/2014 16:50:36: Version MAX ignored.
25/04/2014 16:50:36: Querying version of file '\Windows\.NET CF 2.0\cgacutil.exe.-500~-500~ARMV4I'.
25/04/2014 16:50:36: Version determined to be: 2.0.7045.0.
25/04/2014 16:50:36: Get version completed.
25/04/2014 16:50:36: Querying version of file '\Windows\cgacutil.exe'.
25/04/2014 16:50:36: Version determined to be: 3.5.7283.0.
25/04/2014 16:50:36: Get version completed.
25/04/2014 16:50:36: Suggestion: do not overwrite.
25/04/2014 16:50:36: Delete file '\Windows\.NET CF 2.0\cgacutil.exe.-500~-500~ARMV4I': done.
25/04/2014 16:50:36: Processing alternative file: '\Windows\.NET CF 2.0\mscoree.dll.-500~-500~ARMV4I'.
. . .
25/04/2014 16:50:36: Adding file 'mscorlib.dll': added.
25/04/2014 16:50:36: Adding file 'system.dll': added.
25/04/2014 16:50:36: Adding file 'system.drawing.dll': added.
25/04/2014 16:50:36: Adding file 'system.messaging.dll': added.
25/04/2014 16:50:36: Adding file 'system.web.services.dll': added.
25/04/2014 16:50:36: Adding file 'system.windows.forms.dll': added.
25/04/2014 16:50:36: Adding file 'system.windows.forms.datagrid.dll': added.
25/04/2014 16:50:36: Adding file 'system.xml.dll': added.
25/04/2014 16:50:36: Adding file 'system.net.irda.dll': added.
25/04/2014 16:50:36: Adding file 'system.data.dll': added.
25/04/2014 16:50:36: Adding file 'microsoft.visualbasic.dll': added.
25/04/2014 16:50:36: Adding file 'microsoft.windowsce.forms.dll': added.
25/04/2014 16:50:36: Adding file 'Microsoft.WindowsMobile.DirectX.dll': added.
25/04/2014 16:50:36: Adding file 'CustomMarshalers.dll': added

So the new device has both version 2.0.7045.0 and version 3.5.7283.0 installed.

The old device, according to what is displayed when Windows\cgacutil.exe is run, has 1.0.3316.00 installed.

The problematic project in question has Framework Version set to "v2.0"

The legacy runs on the old device, but not on the new...???

New builds of the source run on neither one. Since it targets Framework Version 2.0, I understand now why the new build won't run on the old device. But why not on the new one? It has CF 2 installed, which corresponds to the Framework Version targeted by the project...

UPDATE 3

I copied the file [appName].exe.config to the handheld device, in the same folder as the .exe

This is the newer (Motorola 3190) device, which supposedly has both CF version 2.* and 3.5* installed.

Attempting to run the legacy (supposedly built for CF 1.0*) exe does, indeed, behave differently with the exe.config file there. Instead of an everlasting hourglass, I get:

**.NET CF Initialization Error**
to run this application, you must first install one of the following versions of the .NET Compact Framework:
v2.0.7045.00
Contact your application publisher for instructions about obtaining the appropriate version of the .NET Compact Framework.

So it tells me to contact myself, which is not of much use.

Why did the text file indicate I had v2.0.7045.00 installed, whereas this indicates that I don't have it installed?

UPDATE 4

It's really macabre/frustrating to me that the text file indicates version 2.* is installed on the device, yet trying to run the latest version there (which has "v2.0" as the "Framework Version" property) fails to run. Hourglasses without the bla.exe.config file, fails with the err msg above with it...?!?

UPDATE 5

I also copied over the latest build of the app (against Framework Version 2) to the older device (the one with Framework 1 installed). I added a [appName].exe.config there with the .exe with these contents:

<configuration>
  <runtime>
      <compatibilityversion major="2" minor="0"/>
v2.0.7045.00
  </runtime>  
  <startup>
      <supportedRuntime version="1.0.3316.00"/>  
  </startup>
</configuration>

...but attempting to run the .exe just results in a momentary hourglass - no err msg, but no joy, either.

UPDATE 6

Experimenting further, I took the project with the opposite problem (Framework Version was v3.5, would run on the newer device, but not on the older one), and edited its .csproj file, changing <TargetFrameworkVersion> from "v3.5" () to "v2.0" (I first tried changing it to "v1.0" but got an error msg: "This project requires .NET Compact Framework v1.0, which is not installed on this machine." so changed it from "v1.0" to "v2.0"

However, that didn't help - that build also does not run on the (older) handheld device...

The err msg tells me, though, that I never before needed to create a Framework Version 1.0 build, as I don't even have that on my dev machine (yet I have previously built versions of our legacy app that did indeed run on both devices). So it seems the device itself has been "messed with" (a newer version of the Compact Framework has been replaced with an older version).

UPDATE 7

Note: The small .exe/utility that runs on the newer device still does after changing Framework Version via the .csproj file from "v3.5" to "v2.0"

UPDATE 8

To further clarify (muddify?) what's going on:

The 3090 Symbol Handheld device has CF version 1.0.3316.00 installed (according to Windows\cgacutil.exe)

The 3190 Motorola Handheld device has no Windows\cgacutil.exe, but has a file that indicates both versions '2.0.7045.00' and '3.5.7338.00' of the Compact Framework are installed on it

The last exe built on a now defunct machine / by a departed developer runs on the 3090 only. It targets CF Framework 1, presumably (since it runs on a device with that version of the CF installed)

It is very odd that that is the case, because prior to his leaving we shared code via TFS, and I was able to run the results (.exe) of the combined code on the devices, and so was he.

The Latest build from my source compiles/builds, but runs on neither the 3090 nor the 3190. It targets CF Framework Version 2.0

A minimalistic utility I built runs on the 3190 only. It targets CF Framework Version 2.0

Does all this give anybody a clue?

UPDATE 9

On this site referenced in IowaEric's answer below it says, "The .NET Compact Framework installs a utility called cgacutil.exe onto each device."

I see that file (cgacutil.exe) on one device, but not the other.

The link above also says, "On Pocket PC or Smartphone devices you can use the File Explorer "

...but I also see no "File Explorer" app[let]; I have Windows Explorer...???

UPDATE 10

Aha! As mentioned in that link, it does work to go to Start > Run... > cgacutil. It tells me "...[3.5.7283.0, 2.0.7045.0]"

(on the 3190; on the 3090 it says "1.0.3316.00")

UPDATE 11

So this is what I've been able to determine about what's on the devices:

OS (Windows CE) version of 3090 == 05.00.1400
OS (Windows CE) version of 3190 == 06.00

CF versions installed on the devices:
Symbol 3090 == 1.0.3316.00
Motorola 3190 == 2.0.7045.0 & 3.5.7283.0

CF Version chart:
1.0.3316.0 == 1.0 SP2
2.0.7045.0 == 2.0 SP2   

Answer

IowaEric picture IowaEric · Apr 29, 2014

I'll be honest. I didn't read your entire question. But in response to the title question, check this question - Programatically check which versions of .NET Compact Framework are installed

I think that WinMo devices can have multiple versions of CF installed.

This site has a little table that will help you map the run time version with the CF release - http://www.christec.co.nz/blog/archives/113

This info is also stored in the registry. To view and edit the registry, you should have a registry editor in c:\program files\ce tools\bin\ I'm not sure of that path, as I'm not at my development pc right now. That might be installed with one of the windows mobile sdks or it might be part of the windows ce power toys install. Google that and you'll find it. Then search the registry for one of those version numbers and you'll have the registry path. Again, if I was at my dev machine I could just tell you. If you're still stuck I can find that for you.