Updated sample code that can detect the .NET Framework 3.5

Now that the .NET Framework 3.5 has been released, I have posted an updated version of the .NET Framework detection sample code that I previously published.  The updated version includes logic to detect the presence of the .NET Framework 3.5 and also .NET Framework 3.0 service packs, which was missing from previous versions of this sample code.

You can download updated versions of the sample code at the following locations:

For reference, the registry locations used in this sample code to detect the .NET Framework 3.0 service pack level and the .NET Framework 3.5 are listed below.

To detect the .NET Framework 3.0 service pack level:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0]
SP = <value>

Note – this SP value will not exist at all if you only have the original release of the .NET Framework 3.0.  This value was added starting in the .NET Framework 3.0 SP1 and will be updated for future service packs.

To detect the .NET Framework 3.5 final release:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5]
Install = 1
Version = 3.5.21022.08

To detect the .NET Framework 3.5 service pack level:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5]
SP = <value>

Note – this SP value does exist in the final release of the .NET Framework 3.5, and will be set to 0.  Future service packs will increment this value as appropriate.

<update date=”4/8/2009″> Fixed broken links to the sample code. </update>


Comments (23)

  1. Meta-Code says:

    Powershell script to get installed versions of the .NET Framework

  2. anony.muos says:

    Hey I have a different question. What happened to the update.exe switches like "/nobackup", "/forcerestart", "/promptrestart" and "/overwriteoem" etc etc. There were so many switches for Update.exe. Are they all removed in Windows Vista? Both pkgmgr.exe and wusa.exe have very limited number of switches.

  3. Hi Someone – Update.exe is only used on OS’s before Windows Vista.  There are a different set of switches, and it looks like not all of the ones offered by update.exe are available from pkgmgr or wusa.  I’m not sure why there is such a big discrepancy, but in at least some of the cases, the command line switches are not relevant anymore because the Windows Vista OS is installed and serviced using an entirely new installation technology.

    There is more information about wusa at http://support.microsoft.com/kb/934307, included supported command line switches.  Wusa is essentially a wrapper around some of the same things that pkgmgr can do.  Pkgmgr can be run with /? to see the syntax of the command line switches, but using it directly requires some specific knowledge about how Windows Vista OS components/packages are composed and it isn’t advised to try to run it directly in most cases.

  4. anony.muos says:

    I don’t see how particularly /forcerestart, /warnrestart, /promptrestart, /overwriteoem, /nobackup, /forceappsclose are all not relevant anymore. Also, the new servicing stack seems to have introduced additional time before, while and after applying any update/hotfix instead of reducing/eliminating it. After every small update/hotfix which is today frequently being delivered over Windows Update, I see the "Configuring updates…please wait" screen for quite some time before logon. Can you blog about what exactly Windows Vista is doing during that time and whether a user can do anything to speed it up? In fact I cannot see how the entirely new servicing stack improves upon the older one except that now its possible to service the image "offline". According to http://technet2.microsoft.com/WindowsVista/en/library/77bd6146-1dae-4f3f-b172-4aa5fc876bdc1033.mspx, package manager does not seem to backup files to %Windir% like Update.exe. What happens then if a user does SFC.EXE and original unpatched files are restored from the Vista DVD? Usually pre-Vista, SFC restored updated/patched files from the backed up location. How is this handled in Vista if no backup is made before patching?

  5. Hi Someone – I didn’t work on the team that created the Vista servicing stack, so I can’t answer all of your questions unfortunately.  Windows Vista stores a copy of each OS file, including each version installed by patches, in %windir%winsxs, and it is not possible to cause Windows Vista to downgrade to unpatched files using sfc.exe without installing the hotfix that contains the newer versions of the files.  Because of that, I don’t think the /nobackup or /overwriteoem switches make sense any more.  I’m not sure about some of the other switches.

    There are some performance issues with the servicing stack that are being worked on for future hotfixes or service packs of Windows Vista.  There isn’t really anything the user can do to speed up the "configuring updates" dialog – that time is being spent by the servicing stack configuring the hotfixes on the system.

  6. dalkema says:

    Too bad there wasn’t a way to query WMI for a list of runtimes.

  7. Hi Dalkema – There are not any pre-built WMI queries to detect the .NET Framework version.  However, the versions of the .NET Framework can be detected by looking up registry values, which I think is a fairly straightforward way of detecting product install state.  Are there some advantages gained by supporting WMI queries for this type of detection as opposed to registry detection?  I am asking because I don’t have much experience using WMI.

  8. The official deployment guides for system administrators and application developers have been posted

  9. The official deployment guides for system administrators and application developers have been posted

  10. There are a several prerequisite dependencies that must be satisfied on a Windows system that does not

  11. There are a several prerequisite dependencies that must be satisfied on a Windows system that does not

  12. Windows Vista and Windows Server 2008 include the .NET Framework 2.0 and 3.0 as OS components. However,

  13. Details about the .NET Framework 2.0 setup packaging Available command line switches for .NET Framework

  14. Question: I am creating an application that is built on the .NET Framework 2.0, and I am attempting to

  15. Question: I have downloaded both versions of the sample .NET Framework version detection code (described

  16. Back when the .NET Framework 3.5 shipped, I posted a brief explanation about the size and contents of

  17. I posted some sample code a while back to demonstrate how to detect whether or not each version of the

  18. Over the weekend, I posted an updated version of the .NET Framework setup verification tool that contains