GetCliVersion Sample

Sample Overview

This sample supports viewing and changing the runtime version number of an assembly. The SSCLI execution environment ignores this value. The .NET Framework common language runtime uses this value to determine which runtime version to load initially when loading an executable assembly. By default, compilers usually emit the version number of the CLI under which the assembly was built. 

The SSCLI runtime version number is v1.0.0. This is a generic runtime version number that will also allow an executable assembly to be loaded by version 1.0 of the .NET Framework. Future versions of the .NET Framework might not support this generic version number.

This sample supports modification of the version number but this is for experimental purposes only. If you modify the runtime version of a strongly named assembly that has been signed, that assembly will no longer load because the signing checksum will have changed. Also, you might not be able to change the version number to a larger number than the existing one in the binary portable executable (PE) assembly file.

The following table shows the command-line options supported by this sample.

OptionDescription
/?
/help
Shows usage information.
/confirmset true|false If true, then sets the version, unloads the file, reopens the file and confirms that the new setting is correct.  The default is false.
/getver Prints the common language runtime version number of the assembly.  This is the default option if only a file name is specified.
/setver Changes the runtime version number within the assembly.

Sample Source and Build Output Locations

The sample source is found in sscli\samples\utilities\getcliversion. 

The source files are:

The build output location is %TARGETCOMPLUS%\samples\utilities\getcliversion.  The output file is an executable assembly named getcliversion.exe.

Building the Sample

All samples are built from the buildall script. 

You can also build all the samples by switching to the root of the sample directory, sscli\samples, and typing build -c.

You can build this specific sample by switching to the sample directory and typing build -c.

Running the Sample

These steps require that the Shared Source CLI (SSCLI) be already built and functional.

  1. Run env.bat or source the env.csh or env.sh script files, depending on your platform.
  2. Switch to the %TARGETCOMPLUS%\samples\utilities\getcliversion directory.
  3. Type the following command:

    clix getcliversion.exe filename

where filename is the name of a managed executable or library assembly. See other options above.


Copyright (c) 2002 Microsoft Corporation. All rights reserved.