如何可靠地检测实际的.NET 4.5版本的安装?可靠、实际、版本、NET

2023-09-02 11:49:55 作者:人丑嘴不甜长得危险还没钱

我实际的问题是,我遇到了两个版本的.NET 4.5全设置:

(可能)旧的一个,这也可以下载SQL Server数据工具时, 大小: 50349920 MD5: a5e81d1b3905ada0a6e35fd6c6a2e1f4 (可能)较新今天上午从这里下载:http://www.microsoft.com/visualstudio/eng/downloads 大小: 50352408 MD5: d02dc8b69a702a47c083278938c4d2f1

版本为设置为 4.5.50709.17929 。内饰方面,主要区别是 netfx_Full.mzz 文件,但即便用与7-ZIP我结束了很多的文件具有相同版本的内容后,文件内容是不同的(我已经从约426查了一下20个随机文件),所以我真的不能分辨出哪一个是新的。

有没有一种方法,以可靠地检测已安装的.NET 4.5运行时的实际版本,这样我就可以只运行,如果它真正需要的设置?

更新

我已经检查了所有的426文件有不同的内容,所有这些都具有两种设置相同的ProductVersion和文件版本。因此,注册表文件或校验和下一个步骤。

更新2

在注册表中列出的版本是相同的两个设置: 4.5.50709

更新3

.NET 4.5.2 现已:

  VS2022 安装.net4.5 亲测有效

该版本的.NET Framework的运行并排侧与.NET Framework 3.5 SP1和更早的版本,但在.NET Framework 4,.NET框架4.5和.NET Framework 4.5执行就地更新0.1。

解决方案

MS最近补丁.NET 4.5恢复与.NET 4.0的向后兼容性在某些情况下(见http://blogs.msdn.com/b/dotnet/archive/2012/10/17/net-framework-4-5-off-to-a-great-start.aspx).

这有可能是MS更新这些变化的安装(以便用户升级到.NET 4.5就不会遇到麻烦compat的),但我不知道为什么他们就不会更改设置的版本号。

另外,还要注意有.NET版本号和所报告的 System.Environment.Version 运行时版本号之间的差异。后者仍然是4.0.30319。*的.NET 4.5中,只有版本号的变化(与.NET 4.5的更新,同时还与每个安全更新)。

下面是运行版本的一些例子在野外观察到的:

基地4.0

4.0.30319.1 = .NET 4.0 RTM 4.0.30319.269 = .NET 4.0在Windows XP SP3,7,7 SP1(含 MS12-035 GDR安全更新) 4.0.30319.276 = .NET 4.0的Windows XP SP3(4.0.3运行时更新) 4.0.30319.296 = .NET 4.0在Windows XP SP3,7(与 MS12-074 GDR安全更新) 4.0.30319.544 = .NET 4.0在Windows XP SP3,7,7 SP1(含 MS12-035 LDR安全更新) 4.0.30319.1008 = .NET 4.0在Windows XP SP3,7,7 SP1(含 MS13-052 GDR安全更新) 4.0.30319.1022 = .NET 4.0在Windows XP SP3,7,7 SP1(含 MS14-009 GDR安全更新) 4.0.30319.1026 = .NET 4.0在Windows XP SP3,7,7 SP1(含 MS14-057 GDR安全更新) 4.0.30319.2034 = .NET 4.0在Windows XP SP3,7,7 SP1(含 MS14-009 LDR安全更新)

4.5

4.0.30319.17626 = .NET 4.5 RC 4.0.30319.17929 = .NET 4.5 RTM 4.0.30319.18010 = .NET 4.5在Windows 8 4.0.30319.18052 = .NET 4.5的Windows 7 SP1 64位 4.0.30319.18063 = .NET 4.5的Windows 7 SP1 64位(与 MS14-009 安全更新)

4.5.1

4.0.30319.18408 = .NET 4.5.1在Windows 7 SP1 64位 4.0.30319.18444 = .NET 4.5.1在Windows 7 SP1 64位(与 MS14-009 安全更新) 4.0.30319.34014 = .NET 4.5.1在Windows 8.1的64位

4.5.2

4.0.30319.34209 = .NET 4.5.2在Windows 7 SP1 64位 4.0.30319.34209 = .NET 4.5.2在Windows 8.1的64位

我没有看到我的Windows更新历史上任何.NET更新,所以我想更新到v18010得到安装为的一部分KB 2756872 。

更新:显然微软更新,由于在原来的下载数字签名的错误在.NET 4.5的设置。 KB 2770445 。

My actual problem is that I have encountered two versions of .NET 4.5 full setups:

a (possibly) older one, which is also available when downloading SQL Server Data Tools size: 50,349,920 md5: a5e81d1b3905ada0a6e35fd6c6a2e1f4 a (possibly) newer one downloaded this morning from here: http://www.microsoft.com/visualstudio/eng/downloads size: 50,352,408 md5: d02dc8b69a702a47c083278938c4d2f1

The version for both setups is 4.5.50709.17929. Inside, the main difference is the netfx_Full.mzz file, but after extracting the content with 7-zip I end up with a lot of files with the same version, even if the file content is different (I have checked about 20 random files from about 426), so I can't really tell which one is newer.

Is there a way to reliably detect the actual version of the installed .NET 4.5 runtime, so I can run the setup only if it's really required?

Update

I have checked all the 426 files that have different content, and all of them are having the same ProductVersion and FileVersion in both setups. So, registry or file checksums are the next step.

Update 2

The version listed in the registry is the same for both setups: 4.5.50709

Update 3

.NET 4.5.2 is now available:

This version of the .NET Framework runs side-by-side with the .NET Framework 3.5 SP1 and earlier versions, but performs an in-place update for the .NET Framework 4, .NET Framework 4.5 and .NET Framework 4.5.1.

解决方案

MS recently patched .NET 4.5 to restore backwards compatibility with .NET 4.0 in some scenarios (see http://blogs.msdn.com/b/dotnet/archive/2012/10/17/net-framework-4-5-off-to-a-great-start.aspx).

It's possible that MS updated the setup with these changes (so that users upgrading to .NET 4.5 don't run into compat trouble), though I don't know why they wouldn't change the version number on the setup.

Also, note that there's a difference between the .NET version number and the runtime version number as reported by System.Environment.Version. The latter still is 4.0.30319.* for .NET 4.5, only the revision number changes (with the .NET 4.5 update, and also with every security update).

Here are some examples of runtime versions observed in the wild:

Base 4.0

4.0.30319.1 = .NET 4.0 RTM 4.0.30319.269 = .NET 4.0 on Windows XP SP3, 7, 7 SP1 (with MS12-035 GDR security update) 4.0.30319.276 = .NET 4.0 on Windows XP SP3 (4.0.3 Runtime update) 4.0.30319.296 = .NET 4.0 on Windows XP SP3, 7 (with MS12-074 GDR security update) 4.0.30319.544 = .NET 4.0 on Windows XP SP3, 7, 7 SP1 (with MS12-035 LDR security update) 4.0.30319.1008 = .NET 4.0 on Windows XP SP3, 7, 7 SP1 (with MS13-052 GDR security update) 4.0.30319.1022 = .NET 4.0 on Windows XP SP3, 7, 7 SP1 (with MS14-009 GDR security update) 4.0.30319.1026 = .NET 4.0 on Windows XP SP3, 7, 7 SP1 (with MS14-057 GDR security update) 4.0.30319.2034 = .NET 4.0 on Windows XP SP3, 7, 7 SP1 (with MS14-009 LDR security update)

4.5

4.0.30319.17626 = .NET 4.5 RC 4.0.30319.17929 = .NET 4.5 RTM 4.0.30319.18010 = .NET 4.5 on Windows 8 4.0.30319.18052 = .NET 4.5 on Windows 7 SP1 64-bit 4.0.30319.18063 = .NET 4.5 on Windows 7 SP1 64-bit (with MS14-009 security update)

4.5.1

4.0.30319.18408 = .NET 4.5.1 on Windows 7 SP1 64-bit 4.0.30319.18444 = .NET 4.5.1 on Windows 7 SP1 64-bit (with MS14-009 security update) 4.0.30319.34014 = .NET 4.5.1 on Windows 8.1 64-bit

4.5.2

4.0.30319.34209 = .NET 4.5.2 on Windows 7 SP1 64-bit 4.0.30319.34209 = .NET 4.5.2 on Windows 8.1 64-bit

I don't see any .NET updates in my Windows Update history, so I guess the update to v18010 got installed as part of KB 2756872.

Update: apparently Microsoft updated the .NET 4.5 setup due a mistake with the digital signatures in the original download. KB 2770445.