.net 4.5 是否与 .net 4.0 并行工作?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10745600/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 16:25:54  来源:igfitidea点击:

Does .net 4.5 work side by side with .net 4.0?

.net.net-4.0.net-4.5

提问by Vaccano

I am interested in installing the .NET 4.5.

我有兴趣安装 .NET 4.5。

But I have heard that it is an In-Place upgrade.

但我听说它是​​就地升级。

Since the users at my company uses Windows XP. I can't release any client side apps that use .NET 4.5.

由于我公司的用户使用 Windows XP。我无法发布任何使用 .NET 4.5 的客户端应用程序。

I know I can target .net 4.0 when I code, but, if I install .net 4.5, is there risk of things working on my machine that will not work on a Windows XP machine (that only has .net 4.0)?

我知道我在编码时可以定位 .net 4.0,但是,如果我安装 .net 4.5,是否存在在我的机器上运行的东西在 Windows XP 机器(只有 .net 4.0)上无法运行的风险?

(By the way, I looked but did not see this question asked. If it has been asked, please point me to it and I will try to delete this one.)

(顺便说一下,我看了看,没看到有人问这个问题。如果有人问过,请指点我,我会尽量删除这个。)

采纳答案by Vaccano

Yes, there are risks of the sort you describe. The .NET 4.0 interface is unchanged, so if you target .NET 4.0, your program will compile and run on XP with .NET 4.0, but the .NET 4.5 implementation of .NET 4.0 contains bugfixes as well. If you rely on .NET Framework not being buggy, and the only available .NET Framework for XP is buggy, your program is going to experience those bugs. I've had this happen with Entity Framework, but there could be other bug fixes as well.

是的,存在您描述的那种风险。.NET 4.0 接口没有改变,所以如果你的目标是 .NET 4.0,你的程序将在 XP 和 .NET 4.0 上编译和运行,但 .NET 4.0 的 .NET 4.5 实现也包含错误修正。如果您依赖 .NET Framework 没有错误,并且唯一可用的 XP 版 .NET Framework 有错误,那么您的程序将会遇到这些错误。我在 Entity Framework 上遇到过这种情况,但也可能有其他错误修复。

回答by Vaccano

I asked this question on the WPF Forum and was given basiclly the same answer that @hvd gave.

我在 WPF 论坛上问了这个问题,得到的答案基本上与 @hvd 给出的答案相同。

http://social.msdn.microsoft.com/Forums/en/wpf/thread/c05a8c02-de67-47a9-b4ed-fd8b622a7e4a

http://social.msdn.microsoft.com/Forums/en/wpf/thread/c05a8c02-de67-47a9-b4ed-fd8b622a7e4a

回答by Jirka Hanika

The accepted answer is very relevant, but let me add an example of a situation where the 4.0 target compiled on a 4.5+ machine is something less useful than a 4.0 with fixed bugs.

接受的答案非常相关,但让我添加一个示例,说明在 4.5+ 机器上编译的 4.0 目标不如带有修复错误的 4.0 有用。

If you have any ComReferencein your projects, they will invoke tlbimp.exefrom .NET 4.5 on the build machine. This may result in your software containing wrappers that reference, for example, a System.Reflection.MethodInfo.CreateDelegate(System.Type)method that only exists in .NET 4.5. You'll get a MissingMethodExceptionon the WinXP machine.

如果您ComReference的项目中有任何项目,它们将tlbimp.exe在构建机器上从 .NET 4.5调用。这可能会导致您的软件包含引用的包装器,例如,System.Reflection.MethodInfo.CreateDelegate(System.Type)仅存在于 .NET 4.5 中的方法。您将MissingMethodException在 WinXP 机器上获得一个。

This happened to me when working with the ComAdminnamespace, which are COM objects for access to the COM+ catalog, but I suspect that the problem may be wider.

我在使用ComAdmin命名空间时发生了这种情况,命名空间是用于访问 COM+ 目录的 COM 对象,但我怀疑问题可能更广泛。