2

I want to check if .Net 2.0 or greater is installed on the machine. I want to check in a way that when newer versions are released the old code works. Registry check is ideal as the code is in C++.

Rohit
  • 3,610
  • 7
  • 45
  • 76
  • [This detailed SO answer](http://stackoverflow.com/questions/199080/how-to-detect-what-net-framework-versions-and-service-packs-are-installed/199783#199783) will tell you which registry keys you need to check. – Zach Johnson Jun 27 '10 at 04:44

2 Answers2

3

This blog post should have all the information you need: Link

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Stephen Cleary
  • 437,863
  • 77
  • 675
  • 810
0

Reading your question quite literally, I would suggest a bootstrapper which does the check, and then launches your .Net app.

Why? Because if your .Net app relies on a specific .Net version (example 3.0), and there is only v2.0 installed on the machine, then your app will crash. If you have a native bootstrapper .exe then you can check the registry using the WinAPI (thousands of examples already exist for this), then launch your .Net app.

An alternative is to check with a bootstrapper that relies only on .Net 2.0 - that version is fairly ubiquitous these days, the chances of a correctly patched and updated machine not having it are fairly small (the chances are greater if it is a pre-WinXP machine). Later versions of the .Net framework are backward compatable with v2.0 (although i am unsure if the reduced nature of the 4.0 CP framework still makes it fully compatable with v2.0).

slugster
  • 49,403
  • 14
  • 95
  • 145