Share via


How to: Configure Runtime Version

You can force an application built with an older version of the .NET Compact Framework version to run on a device installed with a newer version of the .NET Compact Framework, such as version 2.0 or 3.5. The feature is identical to the mechanism for forcing applications in the full .NET Framework to run on the newer version. The .NET Compact Framework provides two settings:

  • <supportedRuntime>

    Specifies the runtime version of the .NET Compact Framework for the application to use.

  • <compatibilityversion>

    Specifies the compatibility mode for a specified version. Note that you should only use this setting for diagnostic purposes.

You can also programmatically use Environment to determine the version.

To determine the currently installed version

  1. On the Pocket PC, use File Explorer to navigate to the \Windows directory and tap the cgacutil file.

  2. A message box appears with the version of the .NET Compact Framework installed on the device.

To set an application to run on version 3.5

  1. Determine the version number of the .NET Compact Framework running on the device. The version number used in this configuration does not include the last period and trailing zeros in the number. For example, "Version 3.5.7121.0" as returned from cgacutil should be "v3.5.7121" in the configuration.

  2. Create a text file with a file name that has ".exe.config" appended to the name of the application, for example, "appname.exe.config".

  3. Add the XML node as shown here to the file with the correct version number for version 3.5:

    <configuration>
      <startup>
        <supportedRuntime version="v3.5.7121"/>
      </startup>
    </configuration>
    
  4. Save the file to the folder that contains the application.

  5. Run the application.

Note

The version number for the .NET Compact Framework 3.5 is subject to change before the final release.

To set an application to run on version 3.5 with compatibility for version 2

  1. Create a text file with a file name that has ".exe.config" appended to the name of the application, for example, "appname.exe.config".

  2. Add the XML node as shown here to the file with the correct version number for version 3.5:

    <configuration>
      <runtime>
        <compatibilityversion major="2" minor="0"/>
      </runtime>  <startup>
        <supportedRuntime version="v3.5.7000"/>
       </startup>
    </configuration>
    
  3. Save the file to the folder that contains the application.

  4. Run the application.

See Also

Other Resources

Building Applications and Core Tasks in the .NET Compact Framework