12
votes

I've encountered a strange problem. I've installed "Visual Studio 2010 ultimate". While installing it showed that it sucessfully installed .NET 4.0. While installing some other softwares. They complain that .NET 2.0 is missing and asking me to install it.

How is it possible? .NET 4.0 must include .NET 2.0 right?

EDIT:

Now, I'm confused. According to this http://en.wikipedia.org/wiki/File:DotNet.svg CLR is part of .NET 2.0. Installing .NET framework 4.0 implies installing the entire stack. which also includes a .NET 2.0. Please clear this confusion.

7
What OS are you on? Vista comes with .NET 2.0 by default, and Windows 7 with .NET 3.5 SP1.Dirk Vollmar
"Must" is quite an assumption to make. .Net 2.0 didn't include .Net 1.0, remember?Dan Puzey

7 Answers

13
votes

No. .NET 4.0 is a standalone CLR, it is NOT based on 2.0, unlike 3.0 and 3.5

8
votes

.NET 4.0 is a new version of the runtime, it is independent of .NET 2.0.

New version of the framework don't encompass the previous versions, they are built as a specific version with a specific featureset. .NET 4.0 has a new runtime and newer BCL (base class library). The BCL essentially has all the same types as the .NET 2.0/3.0/3.5 BCL (albeit with possible breaking changes), and some new stuff. The two framework versions (v2.0 and v4.0) run side-by-side.

The fact that you haven't got .NET 2.0 installed is worrying as it's distributed through the Windows Update service. What OS are you using?

5
votes

The problem is there are two "things" when you refer to .NET 2.0 or .NET 4.0.

It is true that:

  • the .NET 4.5 Framework class library
  • contains everything from the .NET Framework class library
  • contains everything from the .NET 3.5 SP1 Framework class library
  • contains everything from the .NET 3.0 SP2 Framework class library
  • contains everything from the .NET 2.0 SP2 Framework class library
  • contains everything from the .NET 1.1 SP1 Framework class library

Using a helpful diagram from Microsoft's .NET Framework Versions and Dependencies: enter image description here

The issue is that the Framework is different from the Runtime. There are six versions of the .NET Framework, but only four versions of .NET CLR (Common Language Runtime):

  • CLR 1.1: ships with .NET Framework 1.1
  • CLR 2.0: ships with .NET Framework 2.0 SP2, 3.0 SP2, 3.5 SP1
  • CLR 4.0: ships with .NET Framework 4
  • CLR 4.5: ships with .NET Framework 4.5

That means if you install the .NET Framework 4, you can still use the classes you used back in .NET 2. But if your application requires version 2 of the CLR it won't work - because that CLR 2.0 is not installed with .NET Framework 4.0.

4
votes

As others have already said, .net 4.0 has a new CLR which is different from the .net 2.0 CLR.

By default an application will attempt to run on the CLR it was built against.

You can modify the applications.exe.config file with the <SupportedRuntime> element to explicitly tell the system which runtimes the application supports (The order specifies the preference):

<configuration>
   <startup>
      <supportedRuntime version="v2.0.50727"/>
      <supportedRuntime version="v4.0.30319"/>
   </startup>
</configuration>

(Obviously if there is something in your app that is dependant on something in .net 2.0 that has changed then this will still fail)

Unfortunately, if your application is failing to install, that's because the installer is checking explicitly that .net 2.0 exists rather than version>=2.0, if this is the case you could try looking for .zip downloads rather than installers, but other than that there isn't a lot you can do apart from installing .net 2.0 as well - side by side installs of multiple versions are fully supported.

0
votes

If i'm not misstaken, 2010 targets .Net 4.0 framework. Seems like your missing the .Net 2.0 framework on you computer.

0
votes

as far as I know the CLR v2.0.50727 works above v4.0.30319

0
votes

Yes and no - you can run .NET 2 code on the .NET 4 runtime but they are separate runtime engines.

Depending on how the installer checks for .NET it must not be detecting 4 or maybe it's rejecting it as wrong: as ever it's safest to run code in the exact environment it was developed.

2/3.5 is a parallel install. I'd suggest you just install it - it shouldn't cause you any problems.