LINQ在.NET 2.0运行时LINQ、NET

2023-09-02 11:29:49 作者:我的人生,我做主

可以在LINQ启用应用程序运行的机器上只安装了.NET 2.0运行时上?

在理论上,LINQ是语法糖而已,并由此产生IL code应该看起来是一样的,因为它会在.NET 2.0。

我怎么能写LINQ不使用.NET 3.5库?它会在.NET 2.0中运行?

解决方案

有一些黑客,涉及使用System.Core.dll的从3.5框架,使它在.NET 2.0中运行,但我个人不希望用这样一个有点摇摇欲坠的基础。

.NET 学习诀窍 LINQPad

下面请参阅: LINQ的支持。 NET 2.0

     创建一个新的控制台应用程序   仅保留系统和System.Core程序为引用的程序集   设置复制本地为true System.Core程序,因为它不会在.NET 2.0存在   使用LINQ查询的主要方法。例如下面的人。   在建立   所有的bin输出复制到只有.NET 2.0安装在机器   运行   

(需要.NET 2.0 SP1和我不知道,如果捆绑的System.Core.dll的违反EULA)

Can a LINQ enabled app run on a machine that only has the .NET 2.0 runtime installed?

In theory, LINQ is nothing more than syntactic sugar, and the resulting IL code should look the same as it would have in .NET 2.0.

How can I write LINQ without using the .NET 3.5 libraries? Will it run on .NET 2.0?

解决方案

There are some "Hacks" that involve using a System.Core.dll from the 3.5 Framework to make it run with .net 2.0, but personally I would not want use such a somewhat shaky foundation.

See here: LINQ support on .NET 2.0

Create a new console application Keep only System and System.Core as referenced assemblies Set Copy Local to true for System.Core, because it does not exist in .NET 2.0 Use a LINQ query in the Main method. For example the one below. Build Copy all the bin output to a machine where only .NET 2.0 is installed Run

(Requires .net 2.0 SP1 and I have no idea if bundling the System.Core.dll violates the EULA)