Checking for Net Framework

Community Forums/General Help/Checking for Net Framework

Gabriel(Posted 2009) [#1]
I'd like to check if a Net Framework 2.0 application will work on a given target machine. What I'm doing is opening this registry key

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727

And checking if install is set to 1.

But what will happen if .Net 3.0 or 3.5 have been installed? Will a 2.0 application run if only 3.0 or 3.5 have been installed? If so, does the 3.0 and 3.5 installer also set that key for 2.0 to indicate that compatibility is maintained? Or do I need to separately check if the 3.0, 3.5 or 2.0 frameworks have been installed and only refuse to run if ALL of them are not found?


xlsior(Posted 2009) [#2]
Nope, .net has no backwards compatibility: depending on what apps you have, you may end up with 1.0, 1.1, 2.0, 3.0 and 3.5 all installed seperately.

If an app was compiled against dot net 2.0, then whether or not you have 1.1 or 3.0 have installed is completely irrelevant, all that matters is the presence of 2.0.


Gabriel(Posted 2009) [#3]
Oh right, that makes things pretty straightforward, I suppose. What confused me was this from MSDN


The .NET Framework 3.0 adds new technologies to the .NET Framework 2.0, which makes the .NET Framework 3.0 a superset of the .NET Framework 2.0. You can think of .NET Framework 3.0 as an "additive" release to the .NET Framework 2.0, as contrasted with a generational release where software is revised across the board. (For example, the .NET Framework 2.0 was a generational release over the .NET Framework 1.0.)

Because .NET Framework 3.0 is an additive release and uses the core run-time components from .NET Framework 2.0, it is completely backward compatible with the earlier version. Your existing .NET Framework 2.0 based-applications will continue to run without any modifications and you can safely continue your investments using the technologies that shipped with .NET Framework 2.0.



I guess they only mean at a source level, and not including binaries.


xlsior(Posted 2009) [#4]
The catch is that most programs check against a specific version, and if it's not found they'll fail.

Earlier today I ran into a problem with an app refusing to run because I didn't have 1.1 installed, even though I had 2.0 and 3.5.


Gabriel(Posted 2009) [#5]
Well yes, but the MSDN is quite clear that 1.1 to 2.0 was a generational update, not an additive update. Still, you're probably right that the checking mechanism is the key, and that's probably something that .Net applications do automatically unless you disable it. I'll hopefully be able to confirm with the application author, but it sounds as though I should refuse to run it unless 2.0 specifically is installed.


Gabriel(Posted 2009) [#6]
Well the application developer got back to me and gave the opposite answer, but the same advice, so it all works out even. He said that if you have 3.0, 3.5 or newer installed, you have 2.0 so it will work, but that you don't need to separately check for the newer versions. So my simple check for 2.0 should work fine in any case.