Backward Compatibility .NET Framework 4

We have a WPF Application on .net framework 3.5.

Some testers find that they remove .net framework 3.5, but install .net framework 4.0, our APP does not start by itself.

Suppose this means that the .net framework 4.0 does not include all 3.5 libs, and users have to install .net 3.5, although they have 4.0?

I see here some migration issues listed by Microsoft http://msdn.microsoft.com/en-us/library/ee941656.aspx#windows_presentation_foundation_wpf

Do they all break change, so that backward compatibility breaks down?

thank

+16
May 12 '10 at 7:58 a.m.
source share
3 answers

.Net 3.5 / 2.0 Applications do not automatically start in the .NET 4.0 runtime. You must explicitly indicate for your application that it should run on .NET 4.0 in your App.config by adding:

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

If you have third-party components, you also need to mark them as ready for 4.0:

 <configuration> ... <runtime> ... <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> ... <dependentAssembly> <assemblyIdentity name="AssemblyName" publicKeyToken="31bf3856ad364e35"/> <bindingRedirect oldVersion="3.5.0.0-3.5.0.0" newVersion="4.0.0.0"/> </dependentAssembly> ... </assemblyBinding> ... </runtime> ... </configuration> 
+18
May 12 '10 at 8:05 a.m.
source share

different versions work side by side, so yes, they should install 3.5, even if they already installed 4.0. But they will not interfere with each other, so your program will continue to use 3.5 if you do not recompile it for target 4.0 (or configure it to use 4.0 - see below).

As mentioned in this question , microsoft has some recommendations on this issue.

The .NET Framework 4 is very compatible with applications that are created with earlier versions of the .NET Framework, with the exception of some changes that have been made to improve security, standards, correctness, reliability, and performance.

The .NET Framework 4 does not automatically use its version of the common language environment to run applications built with earlier versions of the .NET Framework. To run older applications with the .NET Framework 4, you must compile your application with the target version of the .NET Framework specified in the properties of your project in Visual Studio, or you can specify the supported runtime using the <supportedRuntime> Element in the application configuration file.

You can install .NET 3.5 and .NET 4.0 together with each other. Visual Studio 2010 also includes improved targeting support for .NET 3.5. ScottGu blog for more on this.

EDIT: As already stated, you can reconfigure your application to tell it that if you want to use the 4.0 runtime. it may or may not be normal depending on the bit of your environment. It is safest to install 3.5, but this is not absolutely necessary, although you need to make changes to your config to make it work.

+8
May 12 '10 at 8:02
source share

Thanks to everyone, and thanks to Foxfire, your method works.

And there is one difficult thing that I would like to tell is the order of the nodes.

When I install it as shown below, it works on both 3.5 and 4.0.

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

And if I change the order, APP will fail, only 4.0 will be installed on the OS.

 <startup> <supportedRuntime version="v2.0.50727"/> <supportedRuntime version="v4.0" /> </startup> 
+5
May 13 '10 at 1:16
source share



All Articles