简体   繁体   English

为什么具有相同目标框架版本的两个应用程序的.NET版本不同

[英]Why .NET version is different for two app with same target framework version

Added small code to find .NET version at runtime in: 添加了一些小代码以在运行时查找.NET版本:

  1. sample program 样例程序
  2. proprietary app. 专有应用。

      var version = Environment.Version; Console.WriteLine(version.ToString()); 

Both were compiled with target version .NET Framework 4. 两者都使用目标版本.NET Framework 4进行了编译。

Sample prog output is 4.0.30319.255 样本编输出为4.0.30319.255

proprietary app output is 2.0.50727.8000 专有应用的输出为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. 给我一些指示。

First Check documentation: 首次检查文档:

Environment.Version Property Environment.Version属性

Gets a Version object that describes the major, minor, build, and revision numbers of the common language runtime. 获取一个Version对象,该对象描述公共语言运行时的主要,次要,内部和修订版本号。

Caution 警告

For the .NET Framework 4.5 later, we do not recommend using the Version property to detect the version of the runtime; 对于更高版本的.NET Framework 4.5,我们建议您不要使用Version属性来检测运行时的版本。 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 . 有关更多信息,请参见如何:确定安装了.NET Framework版本

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? 如何在运行时检测到.NET版本4.5当前正在运行您的代码?

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. 使用2.0 vs. 3.0或3.5时,Environment.Version毫无帮助,因为它总是返回2.0,因为所有这些框架版本都使用CLR 2.0。

Read it too: NET Versioning and Multi-Targeting - .NET 4.5 is an in-place upgrade to .NET 4.0 也请阅读: NET版本控制和多目标-.NET 4.5是就地升级到.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. 请注意,此就地替换与.NET 2.0和3.0 / 3.5的并行安装有很大不同,.NET 2.0和3.0 / 3.5均在CLR的2.0版本上运行。 The two 3.x versions were basically library enhancements on top of the core .NET 2.0 runtime. 这两个3.x版本基本上是在核心.NET 2.0运行时之上的库增强。 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. 这两个版本都在.NET 2.0运行时下运行,整个3.x周期都未更改(安全补丁和错误修复除外)。 The 4.5 update instead completely replaces the .NET 4.0 runtime and leaves the actual version number set at v4.0.30319 相反,4.5更新完全替代了.NET 4.0运行时,并将实际版本号设置为v4.0.30319

References: 参考文献:
Why does System.Environment.Version report framework 2? 为什么System.Environment.Version报告框架2?

Environment.Version gives you the version of CLR use, not the .Net framework itself Environment.Version为您提供CLR使用的版本,而不是.Net框架本身

See How do I detect at runtime that .NET version 4.5 is currently running your code? 请参阅如何在运行时检测.NET 4.5当前正在运行您的代码?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Target.NET 框架版本与安装的 .NET 框架版本 - Target.NET framework version vs .NET framework version installed .NET Framework版本在两台不同的计算机之间导致不同的行为? - .NET Framework version causing different behavior between two different machines? 运行时使用的应用程序框架版本目标和Net Framework版本 - Application framework version target and Net Framework version used in runtime 相同的方法,但不同的签名取决于.NET Framework版本? - Same method but different signature depending on .NET framework version? 为什么为相同代码和相同.net框架版本生成的.net dll不是二进制相同的? - Why the .net dlls generated for the same code and same .net framework version are not binary identical? 在其他.net框架版本中执行方法 - Execute a method in a different .net framework version 从WinForms应用程序检查.Net框架版本 - Check on .Net framework version from WinForms app .NET Framework 的目标版本与启动条件不匹配 - Target Version of the .NET Framework does not match Launch Condition 在LINQPad中引用同一程序集的两个不同版本 - reference two different version of the same assembly in LINQPad 有条件地改变目标框架版本 - Conditionally changing target framework version
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM