Finding the .NET version in a debug session

An interesting little question came up on one of our internal discussion groups today.

“How can I find in a debug session the version of the .NET runtime being used in the debuggee?”

[in an automated/scripted fashion and without using debugger extensions or symbols]

Here is what I came up with:

0:029> !for_each_module .if ( ($sicmp( "@#ModuleName" , "mscorwks") = 0) | ($sicmp( "@#ModuleName" , "mscorsvr") = 0) | ($sicmp( "@#ModuleName" , "clr") = 0)) {.echo @#ProductVersion}

2.0.50727.3607

HTH

Doug