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++.
-
[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 Answers
This blog post should have all the information you need: Link

- 21,988
- 13
- 81
- 109

- 437,863
- 77
- 675
- 810
-
-
-
-
@Rohit checking for 2.0 specifically (and possibly 4.0) then is appropriate. 3/3.5 can't be installed independently of 2.0 (in other words, if 3.5 is installed the 2.0 keys will also be present) and 4 is somewhat independent of the prior versions. – Logan Capaldo Jun 27 '10 at 03:57
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).

- 49,403
- 14
- 95
- 145