Search code examples
.netlinq.net-3.5.net-2.0clr

LINQ on the .NET 2.0 Runtime


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?


Solution

  • 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)