Managed Application Runtime Selector


Copyright © 2006, Skybow AG.
See License.txt with this distribution for licensing details.

CLRAS (Run with CLR) allows you to run a managed application with a runtime version of your choice. For example, you can take an application complied against CLR version 1.0 and it run against version 2.0 of the runtime (or vice versa) without making any changes to the application code or configuration files. Sometimes you need to enforce this and other times you just want to test whether a paritcular combination of the application and runtime versions are compatible.

CLRAS itself is a Windows Forms application written with Microsoft .NET Framework 1.0 and has been written in a forward-compatible manner so that it can run against later versions as well. CLRAS can also take command-line arguments that specify which application to run and using which version of the runtime:

clras [ /version ] [ <exe-path> [ exe-args ] ]

All arguments on the command-line are optional. If you simply run CLRAS, you will see a window similar to the following appear:

Display with no arguments

The list box will list the various runtime versions installed on your PC. Select a version, specify the path to the target application in the Run box and click OK. You can specify command-line arguments for the target application in the Run box by using the pipe character (|) as a delimiter (do not confuse this with the pipe character used to pipe applications from the Command Prompt).

If you specify the version argument to CLRAS like this:

clras /v1.1.4322

You will see the version pre-selected and all that will be left to do is specify the executable and click OK:

Display with version argument only

If you omit the version and supply only the executable path (with or without additional command-line arguments), as in:

clras "%ProgramFiles%\NUnit 2.2.5\bin\nunit-gui.exe"

You will see the Run box filled in with the input and all that will be left to do is select the runtime version and click OK:

Display with target executable argument only

Finally, if you supply all parts of the command-line arguments (for example, clras /v1.1.4322 "%ProgramFiles%\NUnit 2.2.5\bin\nunit-gui.exe") then CLRAS will simply attempt to launch the application against that version. It is crucial that you get the version number exactly right. If you just specify, for example, /v2.0, you will see an error like this (you will also see a list of valid values in the error message):

Invalid version error message

All arguments that you specify after the target executable path on the CLRAS command-line are passed on to the launched application. There are some limitations on how the command-line is encoded if you used reserved characters (like & or nested quotes), but it does covers 95% cases.

The About box allows you to also see under which version of the runtime is CLRAS itself running:

About box

The reason for the About box is subtle. You can use CLRAS to run CLRAS itself (recursively) against various runtime versions and then use the About box to confirm it is running under the expected version. In fact, if you do this:

clras.exe clras.exe clras.exe clras.exe clras.exe

You get an interesting effect, assuming CLRAS.EXE is in your PATH. You are passing CLRAS.EXE as an argument to each instance of CLRAS, which allows you to select different runtime versions from the list box and verify using the About box. Each time, one CLRAS.EXE will get popped off the arguments.