Reputation: 31
Added small code to find .NET version at runtime in:
proprietary app.
var version = Environment.Version;
Console.WriteLine(version.ToString());
Both were compiled with target version .NET Framework 4.
Sample prog output is 4.0.30319.255
proprietary app output is 2.0.50727.8000
Sample prog is being compiled and run on same machine.
This proprietary app is getting compiled on one build machine and deployed on other production machine.
Why this difference of version is there.
Where should I look for this issue in proprietary app . Give me some pointers.
Upvotes: 1
Views: 550
Reputation: 18290
First Check documentation:
Environment.Version Property
Gets a Version object that describes the major, minor, build, and revision numbers of the common language runtime.
Caution
For the .NET Framework 4.5 later, we do not recommend using the Version property to detect the version of the runtime; instead, you can determine the version of the common language runtime by querying the registry. For more information, see How to: Determine Which .NET Framework Versions Are Installed.
Refer below link for more clarification about your question:
How do I detect at runtime that .NET version 4.5 is currently running your code?
With 2.0 vs. 3.0 or 3.5 Environment.Version was of no help since it always returned 2.0 as all those framework versions were using the CLR 2.0.
Read it too: NET Versioning and Multi-Targeting - .NET 4.5 is an in-place upgrade to .NET 4.0
Note that this in-place replacement is very different from the side by side installs of .NET 2.0 and 3.0/3.5 which all ran on the 2.0 version of the CLR. The two 3.x versions were basically library enhancements on top of the core .NET 2.0 runtime. Both versions ran under the .NET 2.0 runtime which wasn’t changed (other than for security patches and bug fixes) for the whole 3.x cycle. The 4.5 update instead completely replaces the .NET 4.0 runtime and leaves the actual version number set at v4.0.30319
References:
Why does System.Environment.Version report framework 2?
Upvotes: 1
Reputation: 5733
Environment.Version
gives you the version of CLR use, not the .Net framework itself
See How do I detect at runtime that .NET version 4.5 is currently running your code?
Upvotes: 0