.NET 2.0 运行时上的 LINQ [英] LINQ on the .NET 2.0 Runtime

查看:32
本文介绍了.NET 2.0 运行时上的 LINQ的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

支持 LINQ 的应用能否在仅安装了 .NET 2.0 运行时的机器上运行?

理论上,LINQ 只不过是语法糖,生成的 IL 代码应该与 .NET 2.0 中的代码看起来一样.

如何在不使用 .NET 3.5 库的情况下编写 LINQ?它会在 .NET 2.0 上运行吗?

解决方案

有一些技巧"涉及使用 3.5 框架中的 System.Core.dll 使其与 .net 2.0 一起运行,但我个人不会想用这种有点摇晃的粉底.

请参阅此处:.NET 2.0 上的 LINQ 支持

<块引用>

  1. 创建一个新的控制台应用程序
  2. 仅保留 System 和 System.Core 作为引用程序集
  3. 将 System.Core 的 Copy Local 设置为 true,因为它在 .NET 2.0 中不存在
  4. 在 Main 方法中使用 LINQ 查询.例如下面的那个.
  5. 构建
  6. 将所有 bin 输出复制到仅安装 .NET 2.0 的机器
  7. 运行

(需要 .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

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

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

这篇关于.NET 2.0 运行时上的 LINQ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆