Aaron Stebner's WebLog

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

Checking for the .NET Framework at application runtime, not just at setup time

Checking for the .NET Framework at application runtime, not just at setup time

  • Comments 4

I posted some updated sample code last night that can be used to detect whether or not the various versions of the .NET Framework are installed on a system.  To go along with this sample code, I wanted to also mention a consideration that developers should keep in mind when building an application that relies upon the .NET Framework.

It is common to see an application add code to their setup to check for the .NET Framework and install it as a prerequisite at setup time.  It is less common (at least in my experience) for an application to perform a runtime check in your application startup code to validate that the necessary version of the .NET Framework is installed.

The .NET Framework can be independently uninstalled out from under your application if a user finds it and removes it in the Add/Remove Programs control panel.  I strongly recommend adding logic like I demonstrated in my sample code to your application's startup code paths.  Doing so makes your application more bulletproof and allows you to display more user friendly error messages with exact steps that users can follow to resolve issues related to the .NET Framework.

 

  • PingBack from http://blogs.msdn.com/astebner/articles/574618.aspx
  • >I strongly recommend adding logic...to your application...

    I assume you mean via a _non-managed_ kickstart app that does the check and then hands off control?
  • Hi Dewaynec - That is a good point.  If your main application is written in managed code and the .NET Framework is broken or missing, you won't be able to execute the code to check for the version.  If your application has a non-managed executable as an entry point and then runs managed code later on in the process, it would be very useful to add this kind of a check to make sure the necessary version of the .NET Framework is present on the system at launch time.
  • This guide is intended to serve as a collection of links to articles, tools, tips and tricks that explain

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