2

From a MSDN page, about .NET Framework versions, we know that each version includes all features from the previous versions.

Unlike previous versions of the .NET Framework, the .NET Framework 4 does not allow an application that was built with previous versions of the .NET Framework to migrate forward and run on it if the previous version is not installed

Why is that?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Jader Dias
  • 88,211
  • 155
  • 421
  • 625
  • 3
    Also check out ScottGu's blog post explaining side-by-side installation: http://weblogs.asp.net/scottgu/archive/2009/08/27/multi-targeting-support-vs-2010-and-net-4-series.aspx – doblak Jul 13 '12 at 17:07

4 Answers4

7

As already explained in other answers they are different runtimes so by default the application is not supported because the 2.0 runtime used by .NET 3.5 is not installed.

You can however add the following to the application config to force the application to use the .NET 4.0 runtime:

<startup>
  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>

This however may cause the application to crash because of changes between the different runtimes so the safest is to use the runtime the application targets.

João Angelo
  • 56,552
  • 12
  • 145
  • 147
3

By default they require different runtimes.

The runtime for 3.5 application is the 2.0 runtime and it is not compatible with the 4.0 runtime.

You can retarget as João Angelo explains in his answer.

Community
  • 1
  • 1
Oded
  • 489,969
  • 99
  • 883
  • 1,009
  • 1
    This isn't completely true. The .NET 4 runtime is (mostly) compatible with .NET 2 assemblies, but won't run them without explicitly opting in. – Reed Copsey Jul 13 '12 at 17:14
3

Unlike previous versions of the .NET Framework, the .NET Framework 4 does not allow an application that was built with previous versions of the .NET Framework to migrate forward and run on it if the previous version is not installed

They do, but you have to explicitly allow it to run using the .NET 4 runtime. As the framework has a new runtime, you have to opt in to allowing this if your application targetted an older version.

You can do this by having your app config specify the proper supportedRuntime variables, ie:

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

Without this, the runtime does:

If the element is not present in the application configuration file, the version of the runtime used to build the application is used.

Because you built with CLR 2, only the 2.0 runtime is allowed, so it fails if the user doesn't have .NET 3.5sp1.

Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
1
  • .NET 2.0
  • .NET 3.x is based on .NET 2.0 so both requires .NET 2.0 to be installed
  • .NET 4.0 uses its own version of .NET runtime so you can install it independently
  • .NET 4.5 updates 4.0's runtime
Community
  • 1
  • 1
abatishchev
  • 98,240
  • 88
  • 296
  • 433