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

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

问题描述

可以在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中运行,但我个人不希望用这样一个有点摇摇欲坠的基础。

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

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

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

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

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