微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c# – 运行.NET 4.0应用程序,参考2.0版本的机器上只有4.0框架

这将是一个真正的痛苦尝试复制,所以我希望有人有一个快速的答案…

假设我有一个.NET 4.0应用程序,引用.NET 2.0库(在这种情况下为SharpZipLib).这当然可以在安装了.NET 2.0和4.0的普通机器上正常工作.

如果运行此应用程序的服务器只有.NET 4.0而不是2.0(或3.0 / 3.5等),那么我需要做些什么来允许.NET 2.0库正常运行?

从我所看到的,看起来我可能会把一个配置设置为supportedRuntime,但我不太了解这是什么.

一个配置设置是有效的还是只有.NET 4.0库在这个环境下运行?

(这是一个假设的环境 – 我不打算有自己的服务器4.0,而不是2.0,但如果有人疯了,我想要能够支持他们).

谢谢

解决方法

CLR可以在.net 4.0框架中加载较旧的程序集.

这是一个很好的阅读:

http://msdn.microsoft.com/en-us/magazine/ee819091.aspx

编辑:文章的更新引用.特别注意大胆

The .NET Framework 4 runtime—and all future runtimes—will be able to
run in-process with one another. While we did not back-port this
functionality to older runtimes (1.0 through 3.5),we did make sure
that 4 and beyond will be able to run in-process with any single older
runtime. In other words,you will be able to load 4,5 and 2.0 in the same process,but you will not be able to load 1.1 and 2.0 in the same process. .NET Frameworks 2.0 through 3.5 all run on the 2.0 runtime and so have no conflicts with one another,as shown in figure 2.

原文地址:https://www.jb51.cc/csharp/95058.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐