12

I installed MonoDevelop 2.0 on my Mac.

I created a new Console Application.

"Hello World" program runs fine.

But I can't use Linq.

using System. doesn't show Linq option.

What should I do?

Rubens Mariuzzo
  • 28,358
  • 27
  • 121
  • 148
Sam Kong
  • 5,472
  • 8
  • 51
  • 87

6 Answers6

21

You may need to right-click on your project in the solution view, do Options, Build, General, and set your Target Runtime to Mono / .Net 3.5 or bigger.

Then you can right-click references, do Edit References, and add a reference to System.Core to your project.

Rubens Mariuzzo
  • 28,358
  • 27
  • 121
  • 148
jpobst
  • 9,982
  • 1
  • 29
  • 33
  • 1
    also.. not only the target but YOUR project needs to be 3.5 as well (I had issues where my project was 2.0 and pointing to a mono/net 3.5 proj and it freaked) – KevinDeus Oct 21 '09 at 20:48
  • Thanks a lot. I knew what how to target the runtime but didn't know that I needed to change the core lib. – Evan Plaice Jun 12 '10 at 03:38
6

I'm running Monodevelop 2.0 and Mono 2.0 on Ubuntu 9.04 and lambda's and Linq work fine.

Contrary to what Thomas Levesque says, System.Core does exist in Mono. Extension methods, lambda's et al are all supported.

You need to use using System.Linq.

public static void Example1()    
{

    List<string> people = new List<string>() 
    { 
        "Granville", "John", "Rachel", "Betty", 
        "Chandler", "Ross", "Monica" 
    };

    IEnumerable<string> query = from p in people where p.Length > 5 
    orderby p select p;

    foreach (string person in query) 
    {
        Console.WriteLine(person);
    }
}
Rubens Mariuzzo
  • 28,358
  • 27
  • 121
  • 148
Opflash
  • 496
  • 1
  • 6
  • 12
  • Hi, I added 'using System.Linq' and got the following error when I compiled. [Task:File=/Users/ssk/Projects/Test Linq 4/Test Linq 4/Main.cs, Line=17, Column=50, Type=Error, Priority=Normal, Description=An implementation of `Where' query expression pattern could not be found. Are you missing `System.Linq' using directive or `System.Core.dll' assembly reference?(CS1935)] – Sam Kong May 17 '09 at 02:54
  • What happens when you try to run the example code? Which type are you trying to call Where on? – Opflash May 17 '09 at 10:11
1

Is your Console Application referencing the System.Core.dll? You need to reference it in order to use System.Linq.

Rubens Mariuzzo
  • 28,358
  • 27
  • 121
  • 148
Jordan S. Jones
  • 13,703
  • 5
  • 44
  • 49
1

The Latest version of Mono Develop does support linq. On the project you must select 3.5 under Build/General/RuntimeVersion. After that you can add the System.Core reference.

0

Check if your project references on System.Xml.Linq library too

Subtle Fox
  • 612
  • 7
  • 7
-2

Not sure LINQ is fully implemented within the current release http://www.mono-project.com/Roadmap

Cargowire
  • 1,488
  • 10
  • 21