How to find out the exact version of the .NET platform?

The code:

Console.WriteLine(Environment.Version);

returns identical results (2.0.50727.5448) for the .NET Framework 2.0, 3.0, and 3.5 SP1. How to find out the exact version of the installed .NET platform?

+3
source share
3 answers

You need to read registry keys to detect versions in the granularity of the service pack. This article explains which key / value pairs to look for.

For example, you can specify 3.5from 3.5 SP1by looking at the values ​​inside

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5

"plain" 3.5 has Install = 1, but SP1has SP >=1.

Follow the link to the bottom of the article to see the entire table.

+4
source
System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion()
+4

2.0, 3.0, 3.5, and 3.5SPx are all based on the same set of 2.0 core libraries. In fact, all of these versions 2.0 plus additional components. This answer contains a list of versions: How are the version numbers of the .NET Framework, CLR, and Visual Studio related to each other? and related information.

So, when you ask what version of the runtime will be 2.0 (other options are 1, 1.1, and 4.0, as far as I know).

If you need a 3 / 3.5 / SP distinction, @dasblinkenlight gave you the answer. Otherwise, explain what you are trying to do to get more offers.

+3
source

All Articles