gpt4 book ai didi

linq - 将 .NET 3.5 库与应用程序捆绑在一起,以便在仅安装了 .NET 2.0 的机器上运行?

转载 作者:行者123 更新时间:2023-12-04 06:26:40 25 4
gpt4 key购买 nike

我想在只安装了 .NET Framework 2.0 的机器上使用 LINQ。

我已经阅读过有关 LINQBridge 的文章。但是我不能简单地将“ 复制本地”设置为引用的程序集,例如System.Core.dllSystem.Xml.Linq.dll获得我需要的功能?

有什么缺点吗?这甚至被允许吗?

最佳答案

.Net 3.5 实际上只是带有一些额外 dll 的 .Net 2.0。没有 3.5 运行时。如果包含所需的 dll,应用程序将毫无问题地运行。
来自以下关于 linq 桥评论的文章:http://www.albahari.com/nutshell/linqbridge.aspx

First, it's important to understandthat C# 3.0 and Framework 3.5 aredesigned to work with CLR 2.0—the sameCLR version that Framework 2.0 uses.This means that the C# 3.0 compileremits IL code that runs on the samevirtual machine as before.

This makes Framework 3.5 additive—justas Framework 3.0 wasadditive—comprising additionalassemblies that enhance the existing2.0 Framework and CLR. So there's nothing to stop us from writing ourown assemblies that do the work ofFramework 3.5 (at least, the criticalbits required for local LINQ queries).

The compiler then looks for Where,OrderBy and Select methods. Thecritical thing is that it can findappropriately named methods with thecorrect signatures (typicallyextension methods). But it doesn'tmatter what assembly the methods comefrom. LINQBridge simply providesanother source of these methods—thatare functionally identically to thoseimplemented in the Framework 3.5assemblies.

关于linq - 将 .NET 3.5 库与应用程序捆绑在一起,以便在仅安装了 .NET 2.0 的机器上运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5966564/

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