.NET 2.0 程序集可以在 .NET 4.0 下运行吗?
我开发了一个由多个程序集组成的 .NET 解决方案,其中大多数是针对 .NET Framework 2.0 版本的小型帮助程序集。其余程序集是 MVC 3 Web 应用程序,它们必须面向 .NET Framework 4.0 版本。除了 .NET 和 MVC 框架之外,我的解决方案没有其他外部依赖项。
我的问题如下:当我向客户部署此解决方案时,我是否必须部署两个版本的 .NET Framework,还是可以只部署 4.0 版本? .NET 2.0 程序集可以在 .NET 4.0 下运行吗?
I have developed a .NET solution that consists of several assemblies, most of which are small helper assemblies that target version 2.0 of the .NET Framework. The remaining assemblies are MVC 3 Web applications, which must necessarily target version 4.0 of the .NET Framework. My solution has no other external dependencies besides the .NET and MVC Frameworks.
My question is the following: When I deploy this solution to customers, do I have to deploy both versions of the .NET Framework, or can I just deploy version 4.0? Can .NET 2.0 assemblies run under .NET 4.0?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
是的,嵌入在 .NET 2.0 程序集中的依赖项会自动转换为其 4.0 版本。但它运行时使用的是从未测试过的那些程序集的版本。它们高度兼容,但包含多个错误修复,以及您可能在不知不觉中依赖的错误。没有人能给你100%的保证。
试试吧。
Yes, the dependencies embedded in the assembly on .NET 2.0 assemblies are automatically translated to their 4.0 version. But it runs with a version of those assemblies it has never been tested on. They are highly compatible but contain several bug fixes, bugs that you might unknowingly have a dependency on. Nobody can give you a 100% guarantee.
Just try it.
您只需要最新版本。它是向下兼容的。
You only need the latest version. It's downward compatible.
答案是肯定的,为.NET 2.0开发的程序集将在.NET 4.0下正确运行
The answer is yes, assemblies developed for .NET 2.0 will run correctly under .NET 4.0
是和否(至少对于.Net 4.5)。虽然它向后兼容,但默认情况下是在关联的 .Net 版本上运行代码,如所述 此处:
添加
MyLovely.exe.config
文件后一切正常:Yes and no (at least for .Net 4.5). While it is backwards compatible, the default is to run the code on the associated .Net version as noted here:
After adding a
MyLovely.exe.config
file everything worked fine: