Aaron Stebner's WebLog

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

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

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

  • Comments 18

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>

 

  • Any C# or VB.NET code?
  • 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.
  • Hi Aaron, I just checked out the code and it looks great! Thanks for going the extra mile on this one!
  • Unfortunately, the code only works if the user is logged in as an administrator.
  • 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!
  • Hi Aaron, i don't view this file. Why?
  • 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 ;-)
  • 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.
  • I got a comment from a customer in response to a previous blog post asking about file versions for the...
  • For a VB.NET conversion of this code, visit http://addressof.com/blog/archive/2004/09/21/926.aspx
  • How to detect certain patches applied to .NET 2.0 and Visual Studio 2005.
  • I got a comment from a customer in response to a previous blog post asking about file versions for the

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

  • How to detect certain patches applied to .NET 2.0 and Visual Studio 2005.

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