未处理的异常:Foundation.MonoTouchException:发生<timeout超出=“ =” getting =“” exception =“” details =“”>

时间:2018-10-18 21:47:28

标签: ios xamarin.forms timer crash nstimer

我正在使用Xamarin Forms,并且仅在第一代iPad Mini(iOS 9.3.3(13G34))上看到此问题。

该应用程序可以正常启动,单击后可以正常运行。唯一的问题是当我“按住”按钮时导致崩溃。

错误消息的重要部分可能是这样的:

+[NSTimer scheduledTimerWithTimeInterval:repeats:block:]: unrecognized selector sent to class 0x3b101ed4

未处理的异常:Foundation.MonoTouchException:

现在,此[SO Answer] [1]声明NSTimer是iOS10 + API,因此将不支持iOS9。

我的问题是如何在Xamarin Forms环境中修复它?

谢谢。

完整的错误消息文本:


2018-10-18 14:31:25.805 MyApp.iOS[319:59406] +[NSTimer scheduledTimerWithTimeInterval:repeats:block:]: unrecognized selector sent to class 0x3b101ed4
Unhandled Exception:

Foundation.MonoTouchException: <Timeout exceeded getting exception details>

Thread finished: <Thread Pool> #10
The thread 0xa has exited with code 0 (0x0).
Thread finished: <Thread Pool> #13
The thread 0xd has exited with code 0 (0x0).
2018-10-18 14:31:47.340 MyApp.iOS[319:59406] 
Unhandled Exception:
0   MyApp.iOS                       0x05941e01 setup_stack_trace + 128
1   MyApp.iOS                       0x0594017f mono_handle_exception_internal + 2026
2   MyApp.iOS                       0x0593f991 mono_handle_exception + 50
3   MyApp.iOS                       0x05937837 mono_arm_throw_exception + 118
4   MyApp.iOS                       0x0085ac4c throw_exception + 64
5   MyApp.iOS                       0x05a88390 xamarin_process_managed_exception_gchandle + 60
6   MyApp.iOS                       0x05a8834c xamarin_ftnptr_exception_handler + 24
at (wrapper native-to-managed) ObjCRuntime.Runtime.throw_ns_exception (intptr) [0x00025] in <572357c3f84340a29e439dbdac7629bd#91B547D7-180F-9262-A1A8-072C01C70687>:0
8   MyApp.iOS                       0x05a86228 xamarin_throw_ns_exception + 52
9   MyApp.iOS                       0x05a892b4 _ZL17exception_handlerP11NSException + 288
10  CoreFoundation        
              0x24157c57 <redacted> + 642
11  libobjc.A.dylib                     0x238f309f <redacted> + 174
12  libc++abi.dylib                     0x238e4e17 <redacted> + 78
13  libc++abi.dylib                     0x238e48f9 __cxa_increment_exception_refcount + 0
14  libobjc.A.dylib                     0x238f2f5f objc_exception_rethrow + 42
15  CoreFoundation                      0x240672af CFRunLoopRunSpecific + 654
16  CoreFoundation                      0x24067015 CFRunLoopRunInMode + 108
17  GraphicsServices                    0x25657ac9 GSEventRunModal + 160
18  UIKit                               0x2873b189 UIApplicationMain + 144
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) [0x0004f] in <572357c3f84340a29e439dbdac7629bd#91B547D7-180F-9262-A1A8-072C01C70687>:0
at UIKit.UIApplication.Main (string[],intptr,intptr) [0x00011] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/UIKit/UIApplication.cs:80
at UIKit.UIApplication
.Main (string[],string,string) [0x00034] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/UIKit/UIApplication.cs:64
at MyApp.iOS.Application.Main (string[]) [0x00001] in C:\Projects\MyProject\MyApp\MyApp.iOS\Main.cs:17
at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) [0x0001e] in <7d5a05cfcb09432d8cc656b9d781e54b#91B547D7-180F-9262-A1A8-072C01C70687>:0
24  MyApp.iOS                       0x0594c9c9 mono_jit_runtime_invoke + 824
25  MyApp.iOS                       0x059b6eef mono_runtime_invoke_checked + 102
26  MyApp.iOS                       0x059bb6db mono_runtime_exec_main_checked + 66
27  MyApp.iOS                       0x05934141 mono_jit_exec + 198
28  MyApp.iOS                       0x05a9d174 xamarin_main + 2452
29  MyApp.iOS                       0x002388bd main + 102
30  libdyld.dylib                       0x23d0f873 <redacted> + 2
2018-10-18 14:31:47.344 MyApp.iOS[319:59406] Unhandled managed exception:
Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: +[NSTimer scheduledTimerWithTimeInterval:repeats:block:]: unrecognized selector sent to class 0x3b101ed4
Native stack trace:
    0   CoreFoundation                      0x24157933 <redacted> + 150
    1   libobjc.A.dylib                     0x238f2e17 objc_exception_throw + 38
    2   CoreFoundation                      0x2415d1d1 <redacted> + 0
    3   CoreFoundation                      0x2415aee1 <redacted> + 700
    4   CoreFoundation                      0x24086238 _CF_forwarding_prep_0 + 24
    5   MyApp.iOS                       0x02ae4e68 wrapper_managed_to_native_ObjCRuntime_Messaging_IntPtr_objc_msgSend_Double_bool_IntPtr_intptr_intptr_double_bool_intptr + 156
    6   MyApp.iOS                       0x025eb030 Foundation_NSTimer_CreateScheduledTimer_double_bool_System_Action_1_Foundation_NSTimer + 276
    7   MyApp.iOS                       0x058b39ec MyApp_Forms
_Controls_ExtendedButtonRenderer_OnLongPressed_UIKit_UILongPressGestureRecognizer + 1468
    8   MyApp.iOS                       0x0286d720 UIKit_UILongPressGestureRecognizer_Callback_Activated_UIKit_UILongPressGestureRecognizer + 52
    9   MyApp.iOS                       0x008014a4 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 232
    10  MyApp.iOS                       0x0594c9c9 mono_jit_runtime_invoke + 824
    11  MyApp.iOS                       0x059b6eef mono_runtime_invoke_checked + 102
    12  MyApp.iOS                       0x059b9ac1 mono_runtime_invoke + 56
    13  MyApp.iOS                       0x001e7119 _ZL32native_to_managed_trampoline_212P11objc_objectP13objc_selectorPP11_MonoMethodP28UILongPressGestureRecognizerj + 326
    14  MyApp.iOS                       0x001e6fcf -[__UILongPressGestureRecognizer target:] + 50
    15  UIKit                               0x28c389eb <redacted> + 142
    16  UIKit                               0x2887384f <redacted> +
 170
    17  UIKit                               0x28704ff1 <redacted> + 1004
    18  UIKit                               0x28c39d4f <redacted> + 62
    19  UIKit                               0x286c5a57 <redacted> + 298
    20  UIKit                               0x286c2017 <redacted> + 2902
    21  CoreFoundation                      0x241196c9 <redacted> + 20
    22  CoreFoundation                      0x241179cd <redacted> + 280
    23  CoreFoundation                      0x24117dff <redacted> + 958
    24  CoreFoundation                      0x24067229 CFRunLoopRunSpecific + 520
    25  CoreFoundation                      0x24067015 CFRunLoopRunInMode + 108
    26  GraphicsServices                    0x25657ac9 GSEventRunModal + 160
    27  UIKit                               0x2873b189 UIApplicationMain + 144
    28  MyApp.iOS                       0x02bc227c wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 288
    29  MyApp.iOS                       0x02412044 UIKit_UIApplication_Main_stri
ng___intptr_intptr + 52
    30  MyApp.iOS                       0x02411edc UIKit_UIApplication_Main_string___string_string + 200
    31  MyApp.iOS                       0x0023acb0 MyApp_iOS_Application_Main_string__ + 152
    32  MyApp.iOS                       0x008014a4 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 232
    33  MyApp.iOS                       0x0594c9c9 mono_jit_runtime_invoke + 824
    34  MyApp.iOS                       0x059b6eef mono_runtime_invoke_checked + 102
    35  MyApp.iOS                       0x059bb6db mono_runtime_exec_main_checked + 66
    36  MyApp.iOS                       0x05934141 mono_jit_exec + 198
    37  MyApp.iOS                       0x05a9d174 xamarin_main + 2452
    38  MyApp.iOS                       0x002388bd main + 102
    39  libdyld.dylib                       0x23d0f873 <redacted> + 2
 (Foundation.MonoTouchException)
  at ObjCRuntime.Runtime.ThrowNSException (System.IntPtr ns_exception) [0x00000] in /Library/F
rameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/ObjCRuntime/Runtime.cs:398 
  at ObjCRuntime.Runtime.throw_ns_exception (System.IntPtr exc) [0x00000] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/runtime/Delegates.generated.cs:126 
  at (wrapper native-to-managed) ObjCRuntime.Runtime.throw_ns_exception(intptr)
--- End of stack trace from previous location where exception was thrown ---
  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/UIKit/UIApplication.cs:79 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/UIKit/UIApplication.cs:63 
  at MyApp.iOS.Application.Main (Syst
em.String[] args) [0x00001] in C:\Projects\MyProjects\MyApp\MyApp.iOS\Main.cs:17 
2018-10-18 14:31:47.346 MyApp.iOS[319:59406] critical: Stacktrace:

2018-10-18 14:31:47.346 MyApp.iOS[319:59406] critical: 
Native stacktrace:
2018-10-18 14:31:50.337 MyApp.iOS[319:59406] critical:  0   MyApp.iOS                       0x05940dfd mono_handle_native_crash + 196
2018-10-18 14:31:50.338 MyApp.iOS[319:59406] critical:  1   libsystem_platform.dylib            0x23e86077 _sigtramp + 42
2018-10-18 14:31:50.338 MyApp.iOS[319:59406] critical:  2   libsystem_pthread.dylib             0x23e8c733 pthread_kill + 62
2018-10-18 14:31:50.339 MyApp.iOS[319:59406] critical:  3   libsystem_c.dylib                   0x23d770ad abort + 108
2018-10-18 14:31:50.339 MyApp.iOS[319:59406] critical:  4   MyApp.iOS                       0x05a888b4 xamarin_printf + 0
2018-10-18 14:31:50.339 MyApp.iOS[319:59406] critical:  5   MyApp.iOS                       0x0597bf1f mono_invoke_unhandled_exception_hook + 102
2018-10-18 14:31:50.340 MyApp.iOS[319:59406] critical:  6   MyApp.iOS                       0x0594083b mono_handle_exception_internal + 3750
2018-10-18 14:31:50.340 MyApp.iOS[319:59406] critical:  7   MyApp.iOS                       0x0593f991 mono_handle_exception + 50
2018-10-18 14:31:50.341 MyApp.iOS[319:59406] critical:  8   MyApp.iOS                       0x05937837 mono_arm_throw_exception + 118
2018-10-18 14:31:50.341 MyApp.iOS[319:59406] critical:  9   MyApp.iOS                       0x0085ac4c throw_exception + 64
2018-10-18 14:31:50.341 MyApp.iOS[319:59406] critical:  10  MyApp.iOS                       0x05a88390 xamarin_process_managed_exception_gchandle + 60
2018-10-18 14:31:50.342 MyApp.iOS[319:59406] critical:  11  MyApp.iOS                       0x05a8834c xamarin_ftnptr_exception_handler + 24
2018-10-18 14:31:50.342 MyApp.iOS[319:59406] critical:  12  MyApp.iOS                       0x02bd4f14 wrapper_native_to_managed_ObjCRuntime_Runtime_throw_ns_exception_intptr + 372
2018-10-18 14:31:50.342 MyApp.iOS[319:59406] critical:  13  MyApp.iOS                       0x05a86228 xamarin_throw_ns_exception + 52
2018-10-18 14:31:50.343 MyApp.iOS[319:59406] critical:  14  MyApp.iOS                       0x05a892b4 _ZL17exception_handlerP11NSException + 288
2018-10-18 14:31:50.344 MyApp.iOS[319:59406] critical:  15  CoreFoundation                      0x24157c57 <redacted> + 642
2018-10-18 14:31:50.344 MyApp.iOS[319:59406] critical:  16  libobjc.A.dylib                     0x238f309f <redacted> + 174
2018-10-18 14:31:50.344 MyApp.iOS[319:59406] critical:  17  libc++abi.dylib                     0x238e4e17 <redacted> + 78
2018-10-18 14:31:50.345 MyApp.iOS[319:59406] critical:  18  libc++abi.dylib                     0x238e48f9 __cxa_increment_exception_refcount + 0
2018-10-18 14:31:50.345 MyApp.iOS[319:59406] critical:  19  libobjc.A.dylib                     0x238f2f5f objc_exception_rethrow + 42
2018-10-18 14:31:50.345 MyApp.iOS[319:59406] critical:  20  CoreFoundation                      0x240672af CFRunLoopRunSpecific + 654
2018-10-18 14:31:50.346 MyApp.iOS[319:59406] critical:  21  CoreFoundation                      0x24067015 CFRunLoopRunInMode + 108
2018-10-18 14:31:50.346 MyApp.iOS[319:59406] critical:  22  GraphicsServices                    0x25657ac9 GSEventRunModal + 160
2018-10-18 14:31:50.347 MyApp.iOS[319:59406] critical:  23  UIKit                               0x2873b189 UIApplicationMain + 144
2018-10-18 14:31:50.347 MyApp.iOS[319:59406] critical:  24  MyApp.iOS                       0x02bc227c wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 288
2018-10-18 14:31:50.348 MyApp.iOS[319:59406] critical:  25  MyApp.iOS                       0x02412044 UIKit_UIApplication_Main_string___intptr_intptr + 52
2018-10-18 14:31:50.348 MyApp.iOS[319:59406] critical:  26  MyApp.iOS                       0x02411edc UIKit_UIApplication_Main_string___string_string + 200
2018-10-18 14:31:50.349 MyApp.iOS[319:59406] critical:  27  MyApp.iOS                       0x0023acb0 MyApp_iOS_Application_Main_string__ + 152
2018-10-18 14:31:50.350 MyApp.iOS[319:59406] critical:  28  MyApp.iOS                       0x008014a4 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 232
2018-10-18 14:31:50.351 MyApp.iOS[319:59406] critical:  29  MyApp.iOS                       0x0594c9c9 mono_jit_runtime_invoke + 824
2018-10-18 14:31:50.351 MyApp.iOS[319:59406] critical:  30  MyApp.iOS                       0x059b6eef mono_runtime_invoke_checked + 102
2018-10-18 14:31:50.352 MyApp.iOS[319:59406] critical:  31  MyApp.iOS                       0x059bb6db mono_runtime_exec_main_checked + 66
2018-10-18 14:31:50.352 MyApp.iOS[319:59406] critical:  32  MyApp.iOS                       0x05934141 mono_jit_exec + 198
2018-10-18 14:31:50.352 MyApp.iOS[319:59406] critical:  33  MyApp.iOS                       0x05a9d174 xamarin_main + 2452
2018-10-18 14:31:50.353 MyApp.iOS[319:59406] critical:  34  MyApp.iOS                       0x002388bd main + 102
2018-10-18 14:31:50.353 MyApp.iOS[319:59406] critical:  35  libdyld.dylib                       0x23d0f873 <redacted> + 2
2018-10-18 14:31:50.354 MyApp.iOS[319:59406] critical: 
=================================================================
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.
=================================================================
The app has been terminated.
Failed to Stop app:  An error occured on client IDB4110776 while executing a reply for topic xvs/idb/4.11.0.776/stop-app
The app has been terminated.


  [1]: https://stackoverflow.com/questions/40521799/trivial-nstimer-scheduledtimerwithtimeintervalrepeatsblock-unrecognized

1 个答案:

答案 0 :(得分:0)

您可以使用方法

public static NSTimer CreateScheduledTimer (double seconds, NSObject target, Selector selector, NSObject userInfo, bool repeats)

  

例如

//...
using ObjCRuntime;
//... 
NSTimer.CreateScheduledTimer(0.5, this, new Selector("DelayAction"), null, false);

[Export("DelayAction")]
public void DelayAction()
{
  // do some thing you want
}