Partager via


Sample code to detect .NET Framework 1.0 and 1.1 and service packs

Hey all,

In response to some suggestions from folks who read my blog posts describing how to detect the presence of .NET Framework 1.0 service packs and .NET Framework 1.1 service packs, I wrote up a quick sample application that shows how to implement the detection methods I recommended. You can download the sample code here.

In this sample, I detect the presence of the .NET Framework core packages for 1.0 and 1.1, and then if I find that they are installed, I detect the service pack level also. The sample simply pops up a message box for each version, but could be easily updated to perform some conditional action (as part of a 3rd party setup or something like that).

The code is provided as an example only....I hope it will help better explain how to implement a detection strategy for the .NET Framework and its service packs that will continue to work when future service packs are released. Let me know if you have any problems or questions.....

<update date="6/4/2010"> Fixed broken link to the sample code. </update>

Comments

  • Anonymous
    September 18, 2004
    Any C# or VB.NET code?

  • Anonymous
    September 18, 2004
    I didn't write this sample in managed code because it is used to detect if the .NET Framework is on the machine so it wouldn't even run if it turns out that there is no .NET Framework on the machine. I was also thinking that code would be used as part of another setup package, and I don't recommend using managed code as part of a setup when it can be avoided (due to the additional overhead of the .NET Framework being used during setup). It should be straightforward to convert it from C++ to C#/VB though.

  • Anonymous
    September 19, 2004
    Hi Aaron, I just checked out the code and it looks great! Thanks for going the extra mile on this one!

  • Anonymous
    September 21, 2004
    Unfortunately, the code only works if the user is logged in as an administrator.

  • Anonymous
    September 21, 2004
    It is true that this code requires more than normal user privileges. However, the registry keys being queried are under HKEY_LOCAL_MACHINE, which I believe requires at least Power User privileges. Can you explain what scenarios you would want to use this code as a normal user? Thanks!

  • Anonymous
    September 22, 2004
    Hi Aaron, i don't view this file. Why?

  • Anonymous
    September 23, 2004
    I came across an excellent example that shows how to determine what editions and service pack level of the existing Microsoft .NET Framework is installed. Unfortunately for most of my readers, this code was in C . I've converted the code to VB.NET for everyone to benefit ;-)

  • Anonymous
    September 23, 2004
    Andrea - it appears that there was an issue last night with the site that is hosting the CPP file with this sample code, but it appears to be working fine now.

    If anyone out there still cannot get it to download please send me an email at aaronste (at) microsoft (dot) com and I will send it to you directly.

  • Anonymous
    July 12, 2005
    I got a comment from a customer in response to a previous blog post asking about file versions for the...

  • Anonymous
    December 27, 2005
    For a VB.NET conversion of this code, visit http://addressof.com/blog/archive/2004/09/21/926.aspx

  • Anonymous
    April 07, 2006
    How to detect certain patches applied to .NET 2.0 and Visual Studio 2005.

  • Anonymous
    March 20, 2007
    I got a comment from a customer in response to a previous blog post asking about file versions for the

  • Anonymous
    July 20, 2007
    PingBack from http://blog.lowesoftware.com/software-development/detecting-installed-microsoft-net-framework-clr-version-information

  • Anonymous
    December 04, 2007
    How to detect certain patches applied to .NET 2.0 and Visual Studio 2005.

  • Anonymous
    May 29, 2009
    I previously posted some sample code to detect the version(s) and service pack levels of the .NET Framework

  • Anonymous
    June 04, 2010
    I attempted to access the code at astebner.sts.winisp.net/.../detectFX.cpp.txt but it always times out. Could you please repost and/or email me at copy at j (at) MoonTwist (dot) com Thanks, Casey

  • Anonymous
    June 04, 2010
    Hi BCaseyHanks - That file server no longer exists, but I hadn't have a chance to update this link yet.  You can find an updated download location for this sample code at blogs.msdn.com/.../9763379.aspx now.