Aaron Stebner's WebLog

Thoughts about setup and deployment issues, WiX, XNA, the .NET Framework and Visual Studio

How to detect what .NET Framework 1.1 service pack is installed

How to detect what .NET Framework 1.1 service pack is installed

  • Comments 27

I have seen a few questions on the newsgroups about how to determine whether or not the .NET Framework 1.1 SP1 is installed on your machine.  A colleague pointed me to a KB article that describes a method of looking at file versions to determine this.  We created a new registry hive that started getting installed in the .NET Framework 1.1 specifically to address this and a few other types of detection issues and make this simpler for 3rd party developers, so I wanted to quickly outline how to check for this in the .NET Framework 1.1 and new versions moving forward (it will take a bit for my request to have that KB article updated to go into effect on the live KB site).

Basically you need to query for the existence of a registry value and then check the data in that value.  Here is where it is located:

  • Key Name: HKEY_LOCAL_MACHINE\Software\Microsoft\NET Framework Setup\NDP\v1.1.4322
  • Value: SP
  • Data type: REG_DWORD

The data in this SP value tells you which service pack is installed for the .NET Framework 1.1.  For future versions of the .NET Framework, you will just need to change the part of the key named v1.1.4322 to be the version you are interested in.

Note that this method cannot be used to tell you whether or not you have any QFE's or GDR's installed for the .NET Framework.  If anyone out there needs to be able to detect on this granular of a level, let me know via a comment or email and I can dig into this further.

There are also other alternative ways of detecting the presence of the .NET Framework 1.0 service packs, I will post something about that when I figure out the exact details of how to do that.

Hope this helps....

 

  • Aaron - I was always frustrated by the methodology of determining the version of the .NET framework(s) that are installed. The KB article doesn't help that much if you are trying to programatically determine the version. Worst of all, for each release of the framework, I need to rewrite the detection code. It would be nice if you or Microsoft provided a C++ sample that will return the appropriate installed versions that is somewhat future-proof.
  • MeThink you should explain how to take advantage of the IE user agent string when possible. Combined with the download page of some website, it can provide a more transparent experience.

  • Thank you for the feedback so far. I like the idea of a code sample - I need to do a bit more research on methods of detecting 1.0 SPx before I can code that up, but stay tuned.

    Stephane - can you clarify what you mean by taking advantage of the IE user agent string in your comment?

    Thanks!
  • Thanks, Aaron, that would be great to get a sample together!
  • Is there a KB article about "How to detect WHY the .NET Framework 1.1 service pack is NOT installed"?

    That TargetInvocationException during installation is really annoying... :-(

  • http://blogs.msdn.com/ie/archive/2004/09/02/224902.aspx

    When the .NET run-time is installed, IE6 is updated and it appends whatever is found in the following registry key, in the user agent string of every single web request : HKLM/Software/Microsoft/Windows/CurrentVersio/Internet Settings/5.0/User Agent/Post Platform

  • Is there a reason that the framework doesn't have a way to detect its own version? It's damn useful to have this functionality in Windows, and it seems like it would be a no-brainer to that this would be used elsewhere.
  • Michael - I am sure this is possible. I believe System.Environment.Version gives you this.

    Stephane - I think relying on the User Agent string is a bad idea. Some people change this string using various tweaks to hide (or change) their browser version and its capabilities.
  • There are APIs within the .NET Framework to detect what its own version is, and that can be useful in some scenarios. If you are writing a setup that is trying to bootstrap the .NET Framework, it is likely not going to work to try to make a managed code API call to detect .NET Framework version. Also I wouldn't recommend writing a setup in managed code due to the additional complexity and possible points of failure.

  • "Some people change this string using various tweaks to hide".

    I think this is a ridiculous statement. The 0.01% people who purposedly do this get what they deserve. All others are provided a better user experience with the website able to redirect the user to a proper page, not a default one.
  • Hi Stephane,
    >I think this is a ridiculous statement.
    It certainly sounds that way, but it can be a means of exploit reduction. If I browse with a Firefox string, I can be served up a different exploit than browsing with an IE string. But corner-cases aside, I was referring to detecting the .NET runtime for a setup application, and I would prefer to rely on a 100% method of detecting the available versions, not 99.99%. For web site detection, this is all you have to go on, and yes, people who change it deserve what they get.

  • "and I would prefer to rely on a 100% method of detecting the available versions, not 99.99%".

    No pun intended, but I think you need to take a look at web deployment a bit more. By reading what you say I have that feeling you haven't been doing too much of that install-from-the-web thing.
    Let's get to the point : the first impression from your audience -- potentially customers -- are your web pages, and your setup. It had better be appropriate.
    By being not only appropriate, but even to the point, you are setting yourself well. A seamless .NET detection minimizes the amount of round-trips, default cab and msm modules.
    Even more, a seamless .NET detection reduces the amount of clicks between your home page and the user actually installing the software.
    Sum up all the benefits mentioned in this thread, and compare with the ol' way of doing things.


Page 1 of 2 (27 items) 12
Leave a Comment
  • Please add 5 and 6 and type the answer here:
  • Post