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

前端之家收集整理的这篇文章主要介绍了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.

猜你在找的C#相关文章