I've searched through this group, StackOverflow, and the MT bugzilla list.
There are a lot of mentions about this, but I'm having a hard time finding
an authoritative answer. Assume the following code:

var list = new List<Foo>();
list.Add (new Foo { Id = 3, Name="def"});
list.Add (new Foo { Id = 2, Name="def"});
list.Add (new Foo { Id = 1, Name="ggg"});
var x = from l in list orderby l.Name, l.Id select l;
foreach (var item in x) { ... do something ... }

public class Foo {
  public int Id { get; set; }
  public string Name { get; set; }
}

When running on the device, I get the info pasted below.

Notes:
1. This only fails on the device
2. It doesn't fail if you just have one orderby item

I have a lot of LINQ in my POCO classes, and I wouldn't relish the idea of
unwinding it all.

What do I need to do to make this work?

Unhandled Exception: System.ExecutionEngineException: Attempting to JIT
compile method
'System.Linq.OrderedEnumerable`1<Foo>:CreateOrderedEnumerable<int>
(System.Func`2<Foo, int>,System.Collections.Generic.IComparer`1<int>,bool)'
while running with --aot-only.

  at System.Linq.Enumerable.ThenBy[Foo,Int32] (IOrderedEnumerable`1 source,
System.Func`2 keySelector, IComparer`1 comparer) [0x00007] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq/Enumerable.cs:2787
 
  at System.Linq.Enumerable.ThenBy[Foo,Int32] (IOrderedEnumerable`1 source,
System.Func`2 keySelector) [0x00000] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq/Enumerable.cs:2779
 
  at TestLibrary.HelloContext.List () [0x00006] in
/Users/danmiser/code/MonoTouchRestDemo/TestLibrary/MyClass.cs:18 
  at MonoTouchRestDemo.MonoTouchRestDemoViewController.<ViewDidLoad>m__0
(System.Object sender, System.EventArgs e) [0x00006] in
/Users/danmiser/code/MonoTouchRestDemo/MonoTouchRestDemo/MonoTouchRestDemoViewController.cs:38
 
  at MonoTouch.UIKit.UIControlEventProxy.Activated () [0x00000] in
/Developer/MonoTouch/Source/monotouch/src/UIKit/UIControl.cs:30 
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String
principalClassName, System.String delegateClassName) [0x00042] in
/Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29 
  at MonoTouchRestDemo.Application.Main (System.String[] args) [0x00000] in
/Users/danmiser/code/MonoTouchRestDemo/MonoTouchRestDemo/Main.cs:16 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ExecutionEngineException:
Attempting to JIT compile method
'System.Linq.OrderedEnumerable`1<TestLibrary.HelloClone>:CreateOrderedEnumerable<int>
(System.Func`2<TestLibrary.HelloClone,
int>,System.Collections.Generic.IComparer`1<int>,bool)' while running with
--aot-only.

  at System.Linq.Enumerable.ThenBy[Foo,Int32] (IOrderedEnumerable`1 source,
System.Func`2 keySelector, IComparer`1 comparer) [0x00007] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq/Enumerable.cs:2787
 
  at System.Linq.Enumerable.ThenBy[Foo,Int32] (IOrderedEnumerable`1 source,
System.Func`2 keySelector) [0x00000] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq/Enumerable.cs:2779
 
  at TestLibrary.HelloContext.List () [0x00006] in
/Users/danmiser/code/MonoTouchRestDemo/TestLibrary/MyClass.cs:18 
  at MonoTouchRestDemo.MonoTouchRestDemoViewController.<ViewDidLoad>m__0
(System.Object sender, System.EventArgs e) [0x00006] in
/Users/danmiser/code/MonoTouchRestDemo/MonoTouchRestDemo/MonoTouchRestDemoViewController.cs:38
 
  at MonoTouch.UIKit.UIControlEventProxy.Activated () [0x00000] in
/Developer/MonoTouch/Source/monotouch/src/UIKit/UIControl.cs:30 
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String
principalClassName, System.String delegateClassName) [0x00042] in
/Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29 
  at MonoTouchRestDemo.Application.Main (System.String[] args) [0x00000] in
/Users/danmiser/code/MonoTouchRestDemo/MonoTouchRestDemo/Main.cs:16 
Terminating runtime due to unhandled exception
Stacktrace:


Native stacktrace:

        0   MonoTouchRestDemo                   0x01616970
mono_handle_native_sigsegv + 280
        1   MonoTouchRestDemo                   0x016396c4 
sigabrt_signal_handler +
180
        2   libsystem_c.dylib                   0x331b6539 _sigtramp + 48
        3   libsystem_c.dylib                   0x331abf5b pthread_kill + 54
        4   libsystem_c.dylib                   0x331a4feb abort + 94
        5   MonoTouchRestDemo                   0x016f2774 monoeg_g_logv + 152
        6   MonoTouchRestDemo                   0x016f27c0 
monoeg_assertion_message
+ 52
        7   MonoTouchRestDemo                   0x01600348 mono_thread_abort + 
148
        8   MonoTouchRestDemo                   0x0161653c
mono_handle_exception_internal + 3188
        9   MonoTouchRestDemo                   0x01616740 
mono_handle_exception +
24
        10  MonoTouchRestDemo                   0x016382d8 
mono_arm_throw_exception
+ 172
        11  MonoTouchRestDemo                   0x005c361c throw_exception + 48
        12  MonoTouchRestDemo                   0x01602910 
mono_jit_compile_method
+ 68
        13  MonoTouchRestDemo                   0x016a9ed8 mono_compile_method 
+ 56
        14  MonoTouchRestDemo                   0x01619d10 
common_call_trampoline +
1364
        15  MonoTouchRestDemo                   0x01617de4 
mono_vcall_trampoline +
228
        16  MonoTouchRestDemo                   0x005c3528 
generic_trampoline_vcall
+ 136
        17  MonoTouchRestDemo                   0x003b1c5c
System_Linq_Enumerable_ThenBy_TestLibrary_HelloClone_int_System_Linq_IOrderedEnumerable_1_TestLibrary_HelloClone_System_Func_2_TestLibrary_HelloClone_int
+ 144
        18  MonoTouchRestDemo                   0x003b0ca0
TestLibrary_HelloContext_List + 512
        19  MonoTouchRestDemo                   0x006a9d34
MonoTouchRestDemo_MonoTouchRestDemoViewController__ViewDidLoadm__0_object_System_EventArgs
+ 300
        20  MonoTouchRestDemo                   0x0000edcc
MonoTouch_UIKit_UIControlEventProxy_Activated + 68
        21  MonoTouchRestDemo                   0x0057c188
wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr
+ 200
        22  MonoTouchRestDemo                   0x01602fbc 
mono_jit_runtime_invoke
+ 1644
        23  MonoTouchRestDemo                   0x016ab43c mono_runtime_invoke +
128
        24  MonoTouchRestDemo                   0x01707b54 monotouch_trampoline 
+
3228
        25  CoreFoundation                      0x34321435 -[NSObject
performSelector:withObject:withObject:] + 52
        26  UIKit                               0x3778b9eb -[UIApplication
sendAction:to:from:forEvent:] + 62
        27  UIKit                               0x3778b9a7 -[UIApplication
sendAction:toTarget:fromSender:forEvent:] + 30
        28  UIKit                               0x3778b985 -[UIControl
sendAction:to:forEvent:] + 44
        29  UIKit                               0x3778b6f5 -[UIControl(Internal)
_sendActionsForEvents:withEvent:] + 492
        30  UIKit                               0x3778c02d -[UIControl
touchesEnded:withEvent:] + 476
        31  UIKit                               0x3778a50f -[UIWindow
_sendTouchesForEvent:] + 318
        32  UIKit                               0x37789f01 -[UIWindow 
sendEvent:] +
380
        33  UIKit                               0x377704ed -[UIApplication
sendEvent:] + 356
        34  UIKit                               0x3776fd2d
_UIApplicationHandleEvent + 5808
        35  GraphicsServices                    0x30ba2df3 PurpleEventCallback +
882
        36  CoreFoundation                      0x3439b553
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 38
        37  CoreFoundation                      0x3439b4f5 __CFRunLoopDoSource1 
+
140
        38  CoreFoundation                      0x3439a343 __CFRunLoopRun + 1370
        39  CoreFoundation                      0x3431d4dd CFRunLoopRunSpecific 
+
300
        40  CoreFoundation                      0x3431d3a5 CFRunLoopRunInMode + 
104
        41  GraphicsServices                    0x30ba1fcd GSEventRunModal + 156
        42  UIKit                               0x3779e743 UIApplicationMain + 
1090
        43  MonoTouchRestDemo                   0x00026cfc
wrapper_managed_to_native_MonoTouch_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr
+ 240
        44  MonoTouchRestDemo                   0x006a8f20
MonoTouchRestDemo_Application_Main_string__ + 152
        45  MonoTouchRestDemo                   0x0057c188
wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr
+ 200
        46  MonoTouchRestDemo                   0x01602fbc 
mono_jit_runtime_invoke
+ 1644
        47  MonoTouchRestDemo                   0x016ab43c mono_runtime_invoke +
128
        48  MonoTouchRestDemo                   0x016af6e8 
mono_runtime_exec_main +
436
        49  MonoTouchRestDemo                   0x016b435c 
mono_runtime_run_main +
756
        50  MonoTouchRestDemo                   0x01607344 mono_jit_exec + 140
        51  MonoTouchRestDemo                   0x015ff550 main + 2168
        52  MonoTouchRestDemo                   0x00002504 start + 52

--
View this message in context: 
http://monotouch.2284126.n4.nabble.com/LINQ-and-OrderBy-again-tp4432245p4432245.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to