Framework version

  • Thread starter Thread starter Lou
  • Start date Start date
How can I programmatically get the current framework version?

System.Environment.Version will get you the CLR version loaded into
the process (so it will be 2.0 even if you use 3.x libraries).


Mattias
 
System.Environment.Versionwill get you the CLR version loaded into
the process (so it will be 2.0 even if you use 3.x libraries).

Why is that so? Even if I build a new app under VS 2008 with 3.5 as
the target the Environment.Version returns 2.0....
 
Why is that so? Even if I build a new app under VS 2008 with 3.5 as
the target the Environment.Version returns 2.0....

That's correct. It's because the CLR version hasn't changed, even though
the marketing version for .NET has. .NET 3.0 and 3.5 are still using CLR
2.0, they just have new classes and other features (like a new C# version).

I do think it's a little confusing, but to some extent the question of the
overall .NET version isn't so important since if your application depends
on a specific version it won't get far enough when loading for execution
to get a chance to check the CLR version, and at least for .NET 3.0 and
3.5 there aren't any additions that should affect your own code the way
that a change in the CLR version could.

Pete
 
Back
Top