Forum Xamarin Xamarin.iOS

LINQ Support on iOS

I'm using following versions of Xamarin products.
**Xamarin Studio
Version 4.2.3 (build 59)
Installation UUID: (removed)
Mono 3.2.6 ((no/9b58377)
GTK+ 2.24.23 theme: Raleigh
GTK# (
Package version: 302060000

Apple Developer Tools
Xcode 5.0.2 (3335.32)
Build 5A3005

Version: (Business Edition)
Hash: (removed)
Build date: 2014-17-02 17:43:23-0500**

When i try to use Linq methods like OrderBy or Where I get errors like:
**Missing method System.Linq.Enumerable::OrderBy<[2]>(IEnumerable1<!!0>,Func2<!!0, !!1>,IComparer1<!!1>) ** or **Missing method System.Linq.Enumerable::Where<[1]>(IEnumerable1<!!0>,Func`2<!!0, bool>) **

Everything work on Android. What do I miss?

Best Answers


  • JasonAwbreyJasonAwbrey USInsider, University, Developer Group Leader mod

    Are you including "using System.Linq;" in your code?

    What is the specific line of code that is causing the problem?

  • Yes, System.Linq is in place. Same Code works on Android.

    My port for iOS doesn't.

    I have something like that:
    List a;
    var filtered= a.Where(f=>f.isApproved);

    this is a sample code, but in my original one it's pretty much the same. Of course a is initialized and not empty.

  • JasonAwbreyJasonAwbrey USInsider, University, Developer Group Leader mod

    That should work. You very occasionally will see LINQ issues on iOS due to the AOT compile, which will sometimes choke on LINQ. But a simple Where() shouldn't cause any problems.

  • I'll make some tests when I'm back home.

    To limit investigation scope:
    My Xamarin.iOS and Mono version should support Linq, right?

  • PawelKlimczykPawelKlimczyk PLMember

    I know what is the issue. I have deployed my app from Visual Studio. Did doesn't seem to work. Linq works perfectly when building and deploying from Xamarin Studio under Mac.

    Still strange that native compiler under Mac does not resolve the calls to Linq methods when I build the project in VS....

  • KevinFordKevinFord USUniversity, Certified XTC Partners ✭✭✭

    I seem to be able to recreate this as well when dealing with a view's SubViews collection. That is to say when I deploy through Visual Studio my Linq statement always returns null. When I run the same statement on Xamarin Studio on a Mac it works just fine.

    This is probably something that should be fixed as it makes doing any code in VS a bit difficult. I'll test tomorrow to see if it's just the simulator where it doesn't work or if it doesn't work on a physical device as well.

  • KevinFordKevinFord USUniversity, Certified XTC Partners ✭✭✭

    Though to be fair I don't get an error; it just returns null in VS and I get an object when deploying on Xamarin Studio on a Mac. More research is needed on my part to make sure I fully understand what is happening.

  • prashantvcprashantvc USXamarin Team Xamurai

    @PawelKrzywniak‌ @KevinFord‌ I'm not able to recreate it on my machine, is it possible to post a code snippet that results in the error.

  • PawelKlimczykPawelKlimczyk PLMember

    i tried to debug this(with all necessary classes and so on)
    List<t> a; var filtered= a.Where(f=>f.isApproved);

    in VS2012 connected to my Macintosh and didn't work.

  • suhasini.6926suhasini.6926 USMember

    We are also getting the same problem in IOS Device on Sorting. While running in the Simulator it is working fine and in Device getting the Runtime error when we are using OrderBy in Linq.

Sign In or Register to comment.