The code:
Console.WriteLine(Environment.Version);
returns identical results (2.0.50727.5448) for .NET Framework 2.0, 3.0, and 3.5 SP1. How do I learn the exact version of the installed .NET platform?
The code:
Console.WriteLine(Environment.Version);
returns identical results (2.0.50727.5448) for .NET Framework 2.0, 3.0, and 3.5 SP1. How do I learn the exact version of the installed .NET platform?
System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion()
You need to read registry keys to detect versions at service pack granularity. This article explains what key/value pairs you need to look for.
For example, you can tell 3.5
from 3.5 SP1
by looking at values inside
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5
"plain" 3.5 has Install = 1
, while SP1
has SP >=1
.
Scroll to the bottom of the article at the link to see the entire table.
2.0, 3,0, 3,5 and 3.5SPx all based on the same set of core 2.0 libraries. Essentially all of these versions are 2.0 plus additional components. This answer contains the list of versions: How do the .NET Framework, CLR and Visual Studio version numbers relate to each other? and related information.
So when you ask what run-time environment version is you'll get 2.0 (the other variants are 1, 1.1 and 4.0 as far as I know).
If you need 3/3.5/SP distinction @dasblinkenlight gave you an answer. Otherwise explain what you trying to do to get more suggestions.