ASP.NET Hosting

LINQ support on .NET 2.0

We have a forum for LINQ in Action, where current and future readers can post questions related to the book or to LINQ in general. Here is one question we received recently:

The first chapter states "This means that the applications you’ll build using LINQ can run in a “bare” .NET 2.0 runtime!" ....
Is this true? Or will it require our runtimes to install .NET 3.0 ... or .NET 3.5?

That's right, that's what I wrote in the book. But I hadn't really tried to see what can be achieved. So, here is a small test I did with Visual Studio 2008 Beta 2 and that you can reproduce: 

  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

It should run without any problem. At least it did for me. The sample .NET 3.5 LINQ application I created did run on a machine where neither .NET 3.0 nor .NET 3.5 have been installed ever.

Warning: This may not work in all cases. I know that .NET 2.0 SP1 is installed with .NET 3.5. It may be required under certain circumstances, but I don't know which. In my case, I didn't use .NET 2.0 SP1, and to the best of my knowledge there is not separate installation for it yet anyway.

Update: As Bobby Diaz points out in a comment. .NET 2.0 SP1 is actually required if you want to use LINQ to SQL on .NET 2.0 because it contains an updated version of System.dll! See this forum post for more information.

The sample code I used:

class Program
  static void Main(string[] args)
    var processes =
      from process in System.Diagnostics.Process.GetProcesses()
      where process.ProcessName.StartsWith("s")
      select new {process.Id, Name = process.ProcessName};

    foreach (var process in processes)

Cross-posted from


  • wow that can be a very very good news. will try it today

  • I don't believe it. :)

    The linq expression gets compiled to use extension methods on IEnumerabe from the System.Linq.Queryable static class. This is in the 3.5 System.Core assembly.

    So in the above expression you have where & select which are ultimately calls to Queryable's Where and Select. So where is this code? Is it part of the System.dll in SP1?

  • I'm so sorry.

    I missed step 3 where it says "mark System.Core as Copy Local".

    I did not read the fine post (rtfp).

  • :-)

  • Are there any legal issues with redistributing the .NET 3.5 System.Core dll with your application? (eg - a commercial application)

  • @Xcalibur
    I'm also very interested in the answer to the question about whether it is legal to redistribute System.Core.dll.

  • This is interesting for me as well - Are there any legal issues with redistributing the .NET 3.5 System.Core dll with your application?

  • It's not easy to find information on whether you can redistribute System.Core.dll or not.
    A source of information is Scott Hanselman's blog: "You must not redistribute System.Core.dll to a 3rd party. You mustn't bundle it or ship it with your application."

    The key here may be "3rd party". My understanding is that you can do that inside your company but not outside.
    But this is not really clear. It would be better to know the official policy.

  • Mmmm...

    My current web hosting has only ASP.NET 2.0 and I really want to go for linq.

    But it seems that I cant...

  • Why this works? Easy, the .net framework 2.0, 3.0 and 3.5 works on the same clr (2.0), so every assembly can be reference from 2.0 to upper. It wouldnt work with .net 4.0 because it use another clr with things such as dynamic.
    Congats for this article! keep in mind that Ms sais that it is not remocomended because any assembly could be recompiled in future versions and it wouldnt be very good thing.
    At last, remember that you can do the same with Foundations libraries and any other with 3.5.

    Gabriel Brancolini from Argentina

Comments have been disabled for this content.