Bug 2729 - LINQ failing on device, but works in simulator.
Summary: LINQ failing on device, but works in simulator.
Status: RESOLVED NORESPONSE
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 4.x
Hardware: PC Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-01-03 19:29 UTC by Dominique
Modified: 2013-06-02 12:51 UTC (History)
3 users (show)

Tags: linq
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NORESPONSE

Description Dominique 2012-01-03 19:29:33 UTC
I'm loading an XML file on startup, using the following code...

var xdoc = XDocument.Load(filePath);

mapMarkers = (from c in xdoc.XPathSelectElements("./fixtures/fixture")		
	                let xName = (String)c.Attribute("name")
					let xAge = (int)c.Attribute("age") 
					orderby xAge
	                select new FixtureData() {                    
	                Name = xName,
			Age = xAge,
	                });

notice the "orderby xAge".

I then perform the following LINQ query

var ageGroups = ( from m in mapMarkers
							group m by m.Age into g
							orderby g.Key
							select new { Age = g.Key });
				
				foreach( var ag in ageGroups )
				{
    // DO some funky stuff
}

On Devices, when the foreach statement is hit, the following exception is thrown...

"SystemExecutionEngineException has been thrown
Attempting to JIT compile method 'System.Linq.OrderedSequence'2<<>__AnonType9'2<<>__AnonType8'2.............) while running with --aot-only."

If you now remove the "orderby xAge" statement, everything works on both the device and in the simulator.
Comment 1 Sebastien Pouliot 2012-03-01 19:20:27 UTC
This is one of the generic limitations described in http://docs.xamarin.com/ios/about/limitations#Limited_Generics_Support

It's likely similar to other reported issues (e.g. bug #3114) but we need a complete test case to confirm this (many things vary depending on how things like FixtureData are defined).
Comment 2 Dominique 2012-03-01 19:45:49 UTC
HI Sebastien,
  I'm fairly sure I tried it without the FixtureData and instead using an anonymous type and it still complained.

I'll try and create a full test case for it tomorrow.

Thanks for taking a look at it.

D.
Comment 3 Sebastien Pouliot 2013-06-02 12:51:27 UTC
The 6.3.x beta releases have much improved to avoid this situation (the EngineExecutionException). You might want to try this, or similar code, again and report any remaining issues (with a test case).