VB.NET System.Environment.Version different than target framework

railcrewxpress
railcrewxpress used Ask the Experts™
on
I have a console program where I have set the Target Framework (all configurations) in the Advanced Compile Options to use .NET Framework 3.5. However, when I place MsgBox(System.Environment.Version.ToString) in my code it shows 2.0.50727.5485.

We have an issue with connecting to a web service that the provider suggests might be related to the version of the framework we are using. I'm trying to confirm that we are indeed using 3.5.  

Am I displaying the wrong variable in my code or is it really using 2.0? If it is using 2.0, is there something different I need to do to force it to use 3.5?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
The only true way to know which version of the framework your assembly is built for is to look at the assembly manifest.  One way you can do this is by using ILDASM -Capture.JPGNotice the System.Core version is 3.5.0.0.Now your next question is why does System.Environment.Version display 2.0.50727.5485?

Quite simply because the version of the Common Language Runtime is in fact, 2.0.50727.5485 (which is what Environment.Version reports).Capture.JPGThe same thing happens when you target .NET 4.5, System.Environment.Version displays 4.0.30319.42000; e.g. -Capture.JPGMicrosoft even notes that this is expected behaviour:Capture.JPG- Source

-saige-
Top Expert 2016

Commented:
what you are seeing is the .net clr version and not the net framework version

Author

Commented:
Thank you for your help!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial