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

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.


Comments (4)

  1. dewaynec says:

    >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?

  2. 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.

  3. This guide is intended to serve as a collection of links to articles, tools, tips and tricks that explain

Skip to main content