PDA

View Full Version : getting .net version at runtime


ghell
03-07-2008, 12:57 AM
Is there any way to get the version of the .net runtime that is currently executing an executable? Environment.Version seems to just get the version of the compiler that compiled it. For example when compiling on 1.1 and then executing on 2.0 it returns 1.1.

I am trying to notify my users that they are running 1.1 and should upgrade to 2.0 before I actually migrate the applications to 2.0, but to do this I need to be able to detect when the 1.1 applications are being run under 1.1 not 2.0. This is all assuming that 1.1 applications actually get run by the 2.0 framework if it is installed (i.e. assuming that the 2.0 runtime can run 1.1 applications)

oracleguy
03-07-2008, 01:36 AM
This should be of some help: http://support.microsoft.com/kb/318785

ghell
03-13-2008, 07:09 PM
Thanks for the info. It just gets the installed versions in a fairly basic way though. I would have thought that there would be something in the .net api to get the currently executing version (is this always the highest installed version? on win64 does it always use the 64 bit runtime if both are available, etc). Maybe I can do something sneaky like find out where the machine.config that is being used is located.

Roelf
03-13-2008, 11:24 PM
System.Environment.Version.ToString ()

ghell
04-21-2008, 10:18 AM
As I said, Environment.Version seems to just get the version of the compiler that compiled it. For example when compiling on 1.1 and then executing on 2.0 it returns 1.1.