After hours on the forums I still can't figure this out.
Scenario: I have a table view with expandable lists. When user wants to expand the list clicks on the header and the table refreshes with the new counted values. The table header view is:
[MonoTouch.Foundation.Export("tableView:viewForHeaderInSection:")]
public override UIView GetViewForHeader (UITableView tableView, int section)
{
float headerHeight= ...;
UIView headerView = new UIView (new RectangleF ...);
UIButton button1=new UIButton(new RectangleF (...));
//set label for button
UILabel labelTextButton = new UILabel(new RectangleF ...);
labelTextButton.Text=...;
labelTextButton.Lines=2;
button1.AddSubview(labelTextButton);
button1.TouchUpInside+= (sender, e) =>{
...
tableView.ReloadData();
};
headerView.AddSubview (button1);
return headerView;
}
- When running on the simulator it always gives me an error like this on the first run:
Stacktrace: at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38 at XXX.Mobile.IOS.Application.Main (string[]) [0x00000] in ..../Main.cs:17 at (wrapper runtime-invoke) .runtime_invoke_void_object (object,intptr,intptr,intptr) Native stacktrace: 0 XXXXXXXXX 0x000a4d6c mono_handle_native_sigsegv + 284 1 XXXXXXXXX 0x00018668 mono_sigsegv_signal_handler + 248 2 libsystem_c.dylib 0x96a028cb _sigtramp + 43 3 ??? 0xffffffff 0x0 + 4294967295 4 UIKit 0x018bf258 -[UIApplication send Action:toTarget:fromSender:forEvent:] + 61 5 UIKit 0x01980021 -[UIControl sendAction:to:forEvent:] + 66 6 UIKit 0x0198057f -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 578 7 UIKit 0x0197f6e8 -[UIControl touchesEnded:withEvent:] + 546 8 UIKit 0x01b831d3 _UIGestureRecognizerUpdate + 7407 9 CoreFoundation 0x03ee2afe __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30 10 CoreFoundation 0x03ee2a3d __CFRunLoopDoObservers + 381 11 CoreFoundation 0x03ec07c2 __CFRunLoopRun + 1106 12 CoreFoundation 0x03ebff44 CFRunLoopRunSpecific + 276 13 CoreFoundation 0x03ebfe1b CFRunLoopRunInMode + 123 14 GraphicsServices 0x04e8a7e3 GSEventRunModal + 88 15 GraphicsServices 0x04e8a668 GSEventRun + 104 16 UIKit 0x018bbffc UIApplicationMain + 1211 17 ??? 0x0eeb24ed 0x0 + 250291437 18 ??? 0x0ec26f40 0x0 + 247623488 19 ??? 0x0ec26b48 0x0 + 247622472 20 ??? 0x0ec26c9e 0x0 + 247622814 21 XXXXXXXXX 0x0001ca32 mono_jit_runtime_invoke + 722 22 XXXXXXXXX 0x00180b0e mono_runtime_invoke + 126 23 XXXXXXXXX 0x00184d04 mono_runtime_exec_main + 420 24 XXXXXXXXX 0x0018a0f5 mono_runtime_run_main + 725 25 XXXXXXXXX 0x0007a0c5 mono_jit_exec + 149 26 XXXXXXXXX 0x00218ac4 main + 1988 27 XXXXXXXXX 0x000159cd start + 53 ================================================================= Got a SIGSEGV while executing native code. This usually indicates a fatal error in the mono runtime or one of the native libraries used by your application. =================================================================
The application exits into Simulator Homepage. If I start again the application from the simulator interface (not from MonoTouch) it works perfectly every time.
- When loading the application to the Device:
It works fine the first run, but time to time (3 times per day) the application hangs on the same way as on simulator, but with a different error.
2013-04-10 16:03:16.838 XXXXXXXXX[2480:907] -[CALayer BridgeSelector]: unrecognized selector sent to instance 0x2101da0 2013-04-10 16:03:24.294 XXXXXXXXX[2480:907] Unhandled managed exception: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[CALayer BridgeSelector]: unrecognized selector sent to instance 0x2101da0 (MonoTouch.Foundation.MonoTouchException) at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38 at XXX.Mobile.IOS.Application.Main (System.String[] args) [0x00000] in ...../Main.cs:17 Stacktrace: Native stacktrace: 0 XXXXXXXXX 0x007ff711 mono_handle_native_sigsegv + 244 1 XXXXXXXXX 0x0083b8cd sigabrt_signal_handler + 112 2 libsystem_c.dylib 0x3a847e93 _sigtramp + 42 3 libsystem_c.dylib 0x3a83e123 pthread_kill + 58 4 libsystem_c.dylib 0x3a87a973 abort + 94 5 XXXXXXXXX 0x0089a230 monotouch_throw_monotouch_exception + 0 6 XXXXXXXXX 0x007fd0e9 mono_invoke_unhandled_exception_hook + 92 7 XXXXXXXXX 0x007b55e3 mono_thread_abort + 46 8 XXXXXXXXX 0x007ff3e7 mono_handle_exception_internal + 2138 9 XXXXXXXXX 0x007ff4b5 mono_handle_exception + 12 10 XXXXXXXXX 0x0083ab31 mono_arm_throw_exception + 132 11 XXXXXXXXX 0x003ba468 throw_exception + 68 12 XXXXXXXXX 0x0089a27c monotouch_exception_handler + 0 13 XXXXXXXXX 0x0089a32c objc_skip_type + 0 14 CoreFoundation 0x3252557f + 614 15 libobjc.A.dylib 0x3a3c9a65 + 128 16 libc++abi.dylib 0x39e1607b + 78 17 libc++abi.dylib 0x39e16114 + 19 18 libc++abi.dylib 0x39e17599 cxa_current_exception_type + 0 19 libobjc.A.dylib 0x3a3c99d1 objc_exception_rethrow + 12 20 CoreFoundation 0x3246bf21 CFRunLoopRunSpecific + 456 21 CoreFoundation 0x3246bd49 CFRunLoopRunInMode + 104 22 GraphicsServices 0x360202eb GSEventRunModal + 74 23 UIKit 0x34381301 UIApplicationMain + 1120 24 XXXXXXXXX 0x0013950c wrapper_managed_to_native_MonoTouch_UIKit_UIApplication_UIApplicationMain_int_string_intptr_intptr + 240 25 XXXXXXXXX 0x00674f70 XXX_Mobile_IOS_Application_Main_string__ + 152 26 XXXXXXXXX 0x00384db0 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 200 27 XXXXXXXXX 0x007b7b7f mono_jit_runtime_invoke + 1054 28 XXXXXXXXX 0x008315ab mono_runtime_invoke + 90 29 XXXXXXXXX 0x00834457 mono_runtime_exec_main + 306 30 XXXXXXXXX 0x008346ab mono_runtime_run_main + 482 31 XXXXXXXXX 0x007d35db mono_jit_exec + 94 32 XXXXXXXXX 0x00888584 main + 2220 33 XXXXXXXXX 0x000143e4 start + 40 ================================================================= Got a SIGABRT while executing native code. This usually indicates a fatal error in the mono runtime or one of the native libraries used by your application. =================================================================
I don't know if it's a bug with GC on Monotouch or I am doing something wrong. I've read somewhere that the invalid selector sent to instance was solved. I tried to put breakpoints in the button event handler but it never reaches that point.
Other posts from forum suggested to put variables as global (not a good programming practice), but that didn't work either.
My configuration:
Xamarin Studio Version 4.0.3 (build 13) Runtime: Mono 2.10.12 (mono-2-10/c9b270d) GTK 2.24.16 GTK# (2.12.0.0) Package version: 210120000 Apple Developer Tools Xcode 4.6.1 (2067) Build 4H512 Xamarin.Mac Xamarin.Mac: Not Installed Xamarin.iOS Version: 6.2.2.8 (Business Edition) Build date: 2013-02-04 17:10:37-0400 Build Information Release ID: 400030013 Git revision: fae7c2bde0e8d51943fbd6afa22d7d2bb7a1192f Build date: 2013-03-21 19:16:39+0000 Xamarin addins: 906a1edff23bcfd0ab7518463620a8ee506eaea2 Operating System Mac OS X 10.8.3Thank you for your time
Ovidiu