如何检测安装了哪些 .NET Framework 版本和服务包?

编程入门 行业动态 更新时间:2024-10-11 13:27:19
本文介绍了如何检测安装了哪些 .NET Framework 版本和服务包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在和此处.

A similar question was asked here, but it was specific to .NET 3.5. Specifically, I'm looking for the following:

  • What is the correct way to determine which .NET Framework versions and service packs are installed?
  • Is there a list of registry keys that can be used?
  • Are there any dependencies between Framework versions?
  • 解决方案

    The registry is the official way to detect if a specific version of the Framework is installed.

    Which registry keys are needed change depending on the Framework version you are looking for:

    Framework Version Registry Key ------------------------------------------------------------------------------------------ 1.0 HKLMSoftwareMicrosoft.NETFrameworkPolicyv1.03705 1.1 HKLMSoftwareMicrosoftNET Framework SetupNDPv1.1.4322Install 2.0 HKLMSoftwareMicrosoftNET Framework SetupNDPv2.0.50727Install 3.0 HKLMSoftwareMicrosoftNET Framework SetupNDPv3.0SetupInstallSuccess 3.5 HKLMSoftwareMicrosoftNET Framework SetupNDPv3.5Install 4.0 Client Profile HKLMSoftwareMicrosoftNET Framework SetupNDPv4ClientInstall 4.0 Full Profile HKLMSoftwareMicrosoftNET Framework SetupNDPv4FullInstall

    Generally you are looking for:

    "Install"=dword:00000001

    except for .NET 1.0, where the value is a string (REG_SZ) rather than a number (REG_DWORD).

    Determining the service pack level follows a similar pattern:

    Framework Version Registry Key ------------------------------------------------------------------------------------------ 1.0 HKLMSoftwareMicrosoftActive SetupInstalled Components{78705f0d-e8db-4b2d-8193-982bdda15ecd}Version 1.0[1] HKLMSoftwareMicrosoftActive SetupInstalled Components{FDC11A6F-17D1-48f9-9EA3-9051954BAA24}Version 1.1 HKLMSoftwareMicrosoftNET Framework SetupNDPv1.1.4322SP 2.0 HKLMSoftwareMicrosoftNET Framework SetupNDPv2.0.50727SP 3.0 HKLMSoftwareMicrosoftNET Framework SetupNDPv3.0SP 3.5 HKLMSoftwareMicrosoftNET Framework SetupNDPv3.5SP 4.0 Client Profile HKLMSoftwareMicrosoftNET Framework SetupNDPv4ClientServicing 4.0 Full Profile HKLMSoftwareMicrosoftNET Framework SetupNDPv4FullServicing [1] Windows Media Center or Windows XP Tablet Edition

    As you can see, determining the SP level for .NET 1.0 changes if you are running on Windows Media Center or Windows XP Tablet Edition. Again, .NET 1.0 uses a string value while all of the others use a DWORD.

    For .NET 1.0 the string value at either of these keys has a format of #,#,####,#. The last # is the Service Pack level.

    While I didn't explicitly ask for this, if you want to know the exact version number of the Framework you would use these registry keys:

    Framework Version Registry Key ------------------------------------------------------------------------------------------ 1.0 HKLMSoftwareMicrosoftActive SetupInstalled Components{78705f0d-e8db-4b2d-8193-982bdda15ecd}Version 1.0[1] HKLMSoftwareMicrosoftActive SetupInstalled Components{FDC11A6F-17D1-48f9-9EA3-9051954BAA24}Version 1.1 HKLMSoftwareMicrosoftNET Framework SetupNDPv1.1.4322 2.0[2] HKLMSoftwareMicrosoftNET Framework SetupNDPv2.0.50727Version 2.0[3] HKLMSoftwareMicrosoftNET Framework SetupNDPv2.0.50727Increment 3.0 HKLMSoftwareMicrosoftNET Framework SetupNDPv3.0Version 3.5 HKLMSoftwareMicrosoftNET Framework SetupNDPv3.5Version 4.0 Client Profile HKLMSoftwareMicrosoftNET Framework SetupNDPv4Version 4.0 Full Profile HKLMSoftwareMicrosoftNET Framework SetupNDPv4Version [1] Windows Media Center or Windows XP Tablet Edition [2] .NET 2.0 SP1 [3] .NET 2.0 Original Release (RTM)

    Again, .NET 1.0 uses a string value while all of the others use a DWORD.

    Additional Notes
    • for .NET 1.0 the string value at either of these keys has a format of #,#,####,#. The #,#,#### portion of the string is the Framework version.

    • for .NET 1.1, we use the name of the registry key itself, which represents the version number.

    • Finally, if you look at dependencies, .NET 3.0 adds additional functionality to .NET 2.0 so both .NET 2.0 and .NET 3.0 must both evaulate as being installed to correctly say that .NET 3.0 is installed. Likewise, .NET 3.5 adds additional functionality to .NET 2.0 and .NET 3.0, so .NET 2.0, .NET 3.0, and .NET 3. should all evaluate to being installed to correctly say that .NET 3.5 is installed.

    • .NET 4.0 installs a new version of the CLR (CLR version 4.0) which can run side-by-side with CLR 2.0.

    Update for .NET 4.5

    There won't be a v4.5 key in the registry if .NET 4.5 is installed. Instead you have to check if the HKLMSoftwareMicrosoftNET Framework SetupNDPv4Full key contains a value called Release. If this value is present, .NET 4.5 is installed, otherwise it is not. More details can be found here and here.

    更多推荐

    如何检测安装了哪些 .NET Framework 版本和服务包?

    本文发布于:2023-11-02 10:11:43,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1552094.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:和服务   版本   安装了   Framework   NET

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!