gpt4 book ai didi

c# - 在只有 4.0 框架的机器上引用 2.0 库运行 .NET 4.0 应用程序

转载 作者:可可西里 更新时间:2023-11-01 08:41:34 25 4
gpt4 key购买 nike

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

假设我有一个 .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# - 在只有 4.0 框架的机器上引用 2.0 库运行 .NET 4.0 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8864395/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com