Get latest .NET framework directory

1.3k Views Asked by At

How can I get the latest .NET CLR Install location ?

[System.Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory() is returning the 2.0* location even when the 4.0* is installed.

1

There are 1 best solutions below

0
On

GetRuntimeDirectory() returns the runtime directory of the current running CLR, which if you're getting the 2.0 path means you're not running 4.0 when this code runs, even if it is installed.

Not sure what you're trying to do, but have a look at this article: http://msdn.microsoft.com/en-us/library/hh925568.aspx. Check the InstallPath value under the listed registry keys to get the root path of the framework for a given version.