且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 .NET 4.5 构建的应用程序能否在 .NET 4.0 上运行?

更新时间:2023-10-11 12:10:10

一般来说,这行不通.它在某些情况下确实有效,因为 4.5 是 4.0 的就地替代品,但一般情况下它不会起作用.我个人已经看到类型转移到不同程序集中的问题,并且绑定设置不正确,就像您看到的一样.反射类型并不是 4.5 中唯一移动的类型.

In general, this will not work. It does work in some cases since 4.5 is an in place replacement for 4.0, but it's not going to work in general. I've, personally, seen problems with types that have moved into different assemblies, and the bindings aren't setup correctly, just like you're seeing. The reflection types aren't the only types that were moved in 4.5.

我的项目面向 .NET 4.5.它不使用任何新的 4.5 方法,因此它实际上在仅安装了 .NET 4.0 的机器上运行良好.

My project is targeting to .NET 4.5. It doesn't use any new 4.5 methods, so it actually works fine on the machine with only .NET 4.0 installed.

如果是这种情况,您可以将应用程序更改为面向 .NET 4.0.这应该允许它在仅安装了 .NET 4 的机器上安全运行.

If this is the case, you could just change your application to target .NET 4.0. This should allow it to run safely on a machine with only .NET 4 installed.