Hello Michal, On Tue, Feb 28, 2012 at 12:47 PM, Michal Sartoris <m...@resco.net> wrote: > Hi, > > > > Is there a way how to add event handlers through reflection on iOS? This > piece of code fails on device:
It should be possible. However the linker (enabled by default for devices) can eliminate MoveNextCompleted if it's not used by your code (outside string-based reflection). You can confirm this by using "Don't link" on a device build and fix it by adding a [Preserve] attribute on the event. If that does not work then please fill a bug report on http://bugzilla.xamarin.com and I'll have a look at it. Sebastien > > > var e = target.GetType().GetEvent("MoveNextCompleted"); > > if (e != null) > > e.AddEventHandler(target, new > EventHandler(AsyncEnumerable_MoveNextCompleted)); > > > > with this exception > > > > System.ExecutionEngineException: Attempting to JIT compile method '(wrapper > delegate-invoke) <Module>:invoke_void__this___OnlineEntityQuery_EventHandler > (MobileCrm.UI.OnlineEntityQuery,System.EventHandler)' while running with > --aot-only. > > > > at > System.Reflection.EventInfo.AddEventFrame[OnlineEntityQuery,EventHandler] > (System.Reflection.AddEvent`2 addEvent, System.Object obj, System.Object > dele) [0x00000] in <filename unknown>:0 > > at System.Reflection.EventInfo.AddEventHandler (System.Object target, > System.Delegate handler) [0x0006e] in > /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/EventInfo.cs:100 > > > > Best regards, > > Michal Sartoris > > > _______________________________________________ > MonoTouch mailing list > MonoTouch@lists.ximian.com > http://lists.ximian.com/mailman/listinfo/monotouch > _______________________________________________ MonoTouch mailing list MonoTouch@lists.ximian.com http://lists.ximian.com/mailman/listinfo/monotouch