Help! Our App project crashes on startup with Xamarin.Studio but same works with VS2013.2 ?

PerHungebergMllerPerHungebergMller DKMember ✭✭✭
edited May 2014 in Xamarin.iOS

I recently updated to latest stable versions of Xamarin.iOS, Xamarin.Studio 4.2.5 and Xamarin.iOS 1.12 for VS2013

I am able to run both debug and release versions of out App from VS2013.2 but when I run the exact same project from Xamarin.Studio on Mac it crashes with the following error:

System.ExecutionEngineException: Attempting to JIT compile method 'iSpinLite.UI.iOS.Views.ConnectViewController/<ViewDidLoad>c__async318:MoveNext ()' while running with --aot-only. See for more information. at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start[<ViewDidLoad>c__async318] (iSpinLite.UI.iOS.Views.<ViewDidLoad>c__async318& stateMachine) [0x0001b] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Runtime.CompilerServices/AsyncVoidMethodBuilder.cs:106 at iSpinLite.UI.iOS.Views.ConnectViewController.<ViewDidLoad>m__EF (System.Object sender, MonoTouch.CoreBluetooth.CBDiscoveredPeripheralEventArgs args) [0x00010] in /Users/phm/Desktop/Projects/trunk/iSpinLite/iSpinLite.UI.iOS/Views/ConnectViewController.cs:273 at at (wrapper delegate-invoke) System.EventHandler1<MonoTouch.CoreBluetooth.CBDiscoveredPeripheralEventArgs>:invoke_void__this___object_TEventArgs (object,MonoTouch.CoreBluetooth.CBDiscoveredPeripheralEventArgs)
at iSpinLite.UI.iOS.Utilities.BluetoothHelper.CentralOnDiscoveredPeripheral (System.Object sender, MonoTouch.CoreBluetooth.CBDiscoveredPeripheralEventArgs eventArgs) [0x00034] in /Users/phm/Desktop/Projects/trunk/iSpinLite/iSpinLite.UI.iOS/Utilities/BluetoothHelper.cs:153
at MonoTouch.CoreBluetooth.CBCentralManager+_CBCentralManagerDelegate.DiscoveredPeripheral (MonoTouch.CoreBluetooth.CBCentralManager central, MonoTouch.CoreBluetooth.CBPeripheral peripheral, MonoTouch.Foundation.NSDictionary advertisementData, MonoTouch.Foundation.NSNumber RSSI) [0x00017] in /Developer/MonoTouch/Source/monotouch/src/build/compat/CoreBluetooth/.pmcs-compat.CBCentralManager.g.cs:453
at at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/.pmcs-compat.UIApplication.cs:38
at iSpinLite.UI.iOS.Application.Main (System.String[] args) [0x00008] in /Users/phm/Desktop/Projects/trunk/iSpinLite/iSpinLite.UI.iOS/Main.cs:17

The debugger stops at a simple ViewDidLoad override where I am using the async keyword because I have some await calls it the method.
This has been working before and AFAIK async void overrides should be allowed for events.

public override async void ViewDidLoad() { base.ViewDidLoad(); }

So why is this all of a sudden happening ?

I am unable to deploy our App to AppStore or build working Ad-Hoc archives until I will be able to build a working App via Xamarin.Studio.

I have a Xamarin Business license. Is it possible to get direct Xamarin support ?

I might try to revert back to last known working version of Xamarin.iOS, I think it was 7.2.1, how do I revert to an older Xamarin.iOS version ?


  • PerHungebergMllerPerHungebergMller DKMember ✭✭✭

    Hi again

    The App seems to fail because I made a delegate event be called async:

    public event EventHandler<CBDiscoveredPeripheralEventArgs> DeviceDiscovered = delegate {};

    DeviceDiscovered(this, eventArgs);

    BluetoothHelper.Current.DeviceDiscovered += async (sender, args) =>

    Can I not do this anymore ? As I said it works fine when run from VS2013 update 2.

  • RolfBjarneKvingeRolfBjarneKvinge USXamarin Team Xamurai

    There might be a difference in how mcs and csc compiles your source code.

    I suggest you file a bug at attaching a test project we can use the reproduce it.

    Note that the mcs compiler comes with the Mono runtime.

  • PerHungebergMllerPerHungebergMller DKMember ✭✭✭

    @RolfBjarneKvinge‌, I Will try and make a test project for you and file a bug report.

    As I Said in the earlier post, the App crashes when it tries to execute the code that hocks up the DeviceDiscovered event with an async lampda method.

    So maybe I can avoid this error by declaring the Bluetooth Low Energy Peripheral discovered event in a different Way that makes async work on both mcs and csc compilers ?

  • PerHungebergMllerPerHungebergMller DKMember ✭✭✭

    Hi @RolfBjarneKvinge‌, I have solved the problem.

    Instead of a lambda expression for the Bluetooth Low Energy Device Discovered event, I have re-implemented it with a normal event method and made it async to support my await calls.

    This works flawless with both compilers :-)

    If I get the time I will test this with Xamarin 3 and check that the lambda scenario can work and else submit a bug report with sample project.

    Thank you for your help!

Sign In or Register to comment.