.NET Framework 4.0 does not install when 4.5 is al

2019-01-27 16:17发布

I use Visual Studio 2012 for a WPF project needing (at least) .NET Framework 4.0. I have 4.5 already installed, but people with Windows XP cannot install the application (because 4.5 does not run on Windows XP). I use ClickOnce as the deployment application.

When I try to intall version 4.0, I get the error (translated from Dutch so the English version might be a bit different):

The same or a higher version of .NET Framework 4 is already installed on this computer

How can I fix this?

3条回答
Luminary・发光体
2楼-- · 2019-01-27 16:53

.NET Framework 4.5 is an in-place update and replaces .NET Framework 4. Once you install .NET Framework 4.5 there is no way to go back to .NET Framework 4. Note that major and minor versions of .NET Framework 4.5 assemblies were not changed. This means that a .NET Framework 4 app does not "see" a difference between the two and should run the same way. Since you want apps run on Windows XP you need to target .NET Framework 4 in your project. This will ensure that your app is not using any new APIs added in .NET Framework 4.5. After you do this you should be able to run your app on both .NET Framework 4 and .NET Framework 4.5. Note that even though the compatibility bar was very high (due to .NET Framework 4.5 being an in-place update) you will still find some minor differences (e.g. bugs that caused exceptions in .NET Framework 4 might have been fixed in .NET Framework 4.5 and exceptions are not throw anymore) and therefore you need to test your app on .NET Framework 4 machine thoroughly since running it on .NET Framework 4.5 will not reveal some issues. The reason for this is that targetting ensures that the app is not using APIs that did not exist before but cannot ensure the behavior at runtime since on the machine with .NET Framework 4.5 it will always use .NET Framework 4.5 runtime (since there is no .NET Framework 4 runtime there anymore).

查看更多
做个烂人
3楼-- · 2019-01-27 17:12

Simple, just check the control panel and uninstall the higher version and carry on with the installation.

查看更多
萌系小妹纸
4楼-- · 2019-01-27 17:14

.NET 4.5 is an add-on to .NET 4.0 in terms of the CLR, and as such, when you install .NET 4.5, it includes 4.0. There is a known issue with ClickOnce when it is generated on a machine that has .NET 4.5 installed.

Visual Studio 2012 Update 1 is supposed to fix this issue.

You can set the .NET framework version for your .NET applications inside Visual Studio. When you want to publish a Windows XP compatible version, you should always select .NET 4 or lower as the target framework.

The .NET 4.0 Framework should be listed side by side with 4.5.

Enter image description here

This is on a normally installed Windows 8 machine, Visual Studio 2012 Ultimate, without having to install any other framework or SDK.

查看更多
登录 后发表回答