views:

1370

answers:

6

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?

Thanks.

A: 

Is your Console Application referencing the System.Core.dll?

Jordan S. Jones
A: 

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

Cargowire
+5  A: 

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"

Test Example 
public static void Example1()

{

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

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

    foreach (string person in query) 
    {
        Console.WriteLine(person);
    }
}
JC Denton
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
What happens when you try to run the example code? Which type are you trying to call Where on?
JC Denton
So Mono is more advanced than I thought... cool :)
Thomas Levesque
+12  A: 

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.

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

jpobst
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
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
+1  A: 

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.

A: 

My god, I don't know why that was so hard to find. Thank you for telling me where I can finally get System.Core for my c# mono.