设备上的 NotSupportedException
NotSupportedException on Device
我开始遇到这个非常奇怪的问题,应用程序在 iOS 模拟器上运行良好,但是当我在设备上启动它时,它显示登录屏幕,但在登录后,它崩溃了"Operation is not supported" 异常。堆栈跟踪完全无法理解:
2015-03-19 13:05:58.256 MemberLinkApp[886:353839] Unhandled managed exception: Operation is not supported. (System.NotSupportedException)
at ObjCRuntime.Runtime.GetGenericMethodDirect (IntPtr obj, IntPtr typeptr, IntPtr methodptr, Int32 paramCount, System.IntPtr* paramptr) [0x00035] in /Developer/MonoTouch/Source/maccore/src/ObjCRuntime/Runtime.cs:248
at ObjCRuntime.Runtime.get_generic_method_direct (IntPtr obj, IntPtr typeptr, IntPtr methodptr, Int32 paramCount, System.IntPtr* paramptr) [0x00000] in /Developer/MonoTouch/Source/maccore/runtime/Delegates.generated.cs:184
at (wrapper native-to-managed) ObjCRuntime.Runtime:get_generic_method_direct (intptr,intptr,intptr,int,intptr*)
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:62
at UIKit.UIApplication.Main (System.String[] args, Syst
em.String principalClassName, System.String delegateClassName) [0x0001c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:45
at MemberLink.App.iOS.Application.Main (System.String[] args) [0x00002] in c:\Projects\memberlink\App\MemberLink.App.iOS\Main.cs:37
2015-03-19 13:05:58.260 MemberLinkApp[886:353839] critical: Stacktrace:
2015-03-19 13:05:58.261 MemberLinkApp[886:353839] critical:
Native stacktrace:
2015-03-19 13:05:59.556 MemberLinkApp[886:353839] critical: 0 MemberLinkApp 0x02b940d1 mono_handle_native_sigsegv + 240
2015-03-19 13:05:59.557 MemberLinkApp[886:353839] critical: 1 MemberLinkApp 0x02b9947b sigabrt_signal_handler + 102
2015-03-19 13:05:59.558 MemberLinkApp[886:353839] critical: 2 libsystem_platform.dylib 0x30c8c0a3 _sigtramp + 42
2015-03-19 13:05:59.559 MemberLinkApp[886:353839] critical: 3 libsystem_pthread.dylib 0x30c91c97 pthread_kill + 62
2015-03-19 13:05:59.560 MemberLinkApp[886:353839] critical: 4 libsystem_c.dylib 0x30bb0939 abort + 76
2015-03-19 13:05:59.561 MemberLinkApp[886:353839] critical: 5 MemberLinkApp 0x02c56b68 fetch_virt_property + 0
2015-03-19 13:05:59.562 MemberLinkApp[886:353839] critical: 6 MemberLinkApp 0x02b94643 mono_invoke_unhandled_exception_hook + 66
2015-03-19 13:05:59.562 MemberLinkApp[886:353839] critical: 7 MemberLinkApp 0x02ba10ef mono_thread_abort_dummy + 62
2015-03-19 13:05:59.563 MemberLinkApp[886:353839] critical: 8 MemberL
inkApp 0x02b93d91 mono_handle_exception_internal + 3964
2015-03-19 13:05:59.564 MemberLinkApp[886:353839] critical: 9 MemberLinkApp 0x02b92e0f mono_handle_exception + 10
2015-03-19 13:05:59.565 MemberLinkApp[886:353839] critical: 10 MemberLinkApp 0x02b8ca93 mono_arm_throw_exception + 110
2015-03-19 13:05:59.566 MemberLinkApp[886:353839] critical: 11 MemberLinkApp 0x00f8a780 rethrow_exception + 68
2015-03-19 13:05:59.567 MemberLinkApp[886:353839] critical: 12 MemberLinkApp 0x00f2d5d4 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 200
2015-03-19 13:05:59.568 MemberLinkApp[886:353839] critical: 13 MemberLinkApp 0x02ba0893 mono_jit_runtime_invoke + 1162
2015-03-19 13:05:59.569 MemberLinkApp[886:353839] critical: 14 MemberLinkApp 0x02be8739 mono_runtime_invoke + 88
2015-03-19 13:05:59.570 MemberLinkApp[886:353839] critical: 15 MemberLinkApp 0x02bebc4b mono_runtime_exec_main + 282
2015-03-19 13:05:59.571 MemberLinkApp[886:353839] critical: 16 MemberLinkApp 0x02beba89 mono_runtime_run_main + 492
2015-03-19 13:05:59.571 MemberLinkApp[886:353839] critical: 17 MemberLinkApp 0x02b8a819 mono_jit_exec + 48
2015-03-19 13:05:59.572 MemberLinkApp[886:353839] critical: 18 MemberLinkApp 0x02c511bc xamarin_main + 2172
2015-03-19 13:05:59.573 MemberLinkApp[886:353839] critical: 19 MemberLinkApp 0x02b6d33d main + 108
2015-03-19 13:05:59.574 MemberLinkApp[886:353839] critical: 20 libdyld.dylib 0x30b4baaf <redacted> + 2
2015-03-19 13:05:59.575 MemberLinkApp[886:353839] critical:
================================
即使我启用了对所有异常的中断,它仍然不会中断,直到 Main。
我已经断定 HTTP 工作正常,因为登录功能工作顺利。在这一点上我对问题是什么一无所知,因为就像我说的,它在模拟器上工作正常。
OS & 软件信息:
- VS2013 SP4
- (Windows) Xamarin Studio 5.7.2(内部版本 7)
- (Mac) Xamarin Studio 5.8(内部版本 443)
- Xamarin.iOS 8.8.0.2
- Xamarin 构建主机 3.9.0.483
- Windows 8.1 Enterprise 运行 作为 Mac OS
上的并行虚拟机
Nuget 包:
- Newtonsoft.Json
- Microsoft.Net.Http
- Microsoft.Net.Async
- Microsoft.Bcl
- Fody & ProperyChanged.Fody(也确认它工作正常)
其他图书馆:
- Xamarin.iOS(统一API)
- MonoTouch.Dialog
其他技术:
- 故事板文件
- Nib (.xib) 文件
@Edit:经过进一步测试,我得出结论,当我在我的 UITabBarController
上设置 ViewControllers 属性 时会抛出此异常
有史以来最奇怪的问题,但我想通了。
所以这很好用:
MyViewController : MvvmViewController<RandomViewModel>
但是,一旦我这样做:
EmbeddedViewController : MvvmViewController<RandomViewModel>
并在 Container View 中使用它(您只能通过设计器放置的控件,因为它在幕后做了一些魔术),它变得疯狂。而且不只是一点点,而是真的很生气。
所以我必须做的是直接从 UIViewController 继承,然后它起作用了。
我唯一能看到的应该是一个问题,就是我继承了一个带有泛型参数的 class,我们都知道 iOS 多么讨厌泛型。
我开始遇到这个非常奇怪的问题,应用程序在 iOS 模拟器上运行良好,但是当我在设备上启动它时,它显示登录屏幕,但在登录后,它崩溃了"Operation is not supported" 异常。堆栈跟踪完全无法理解:
2015-03-19 13:05:58.256 MemberLinkApp[886:353839] Unhandled managed exception: Operation is not supported. (System.NotSupportedException)
at ObjCRuntime.Runtime.GetGenericMethodDirect (IntPtr obj, IntPtr typeptr, IntPtr methodptr, Int32 paramCount, System.IntPtr* paramptr) [0x00035] in /Developer/MonoTouch/Source/maccore/src/ObjCRuntime/Runtime.cs:248
at ObjCRuntime.Runtime.get_generic_method_direct (IntPtr obj, IntPtr typeptr, IntPtr methodptr, Int32 paramCount, System.IntPtr* paramptr) [0x00000] in /Developer/MonoTouch/Source/maccore/runtime/Delegates.generated.cs:184
at (wrapper native-to-managed) ObjCRuntime.Runtime:get_generic_method_direct (intptr,intptr,intptr,int,intptr*)
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:62
at UIKit.UIApplication.Main (System.String[] args, Syst
em.String principalClassName, System.String delegateClassName) [0x0001c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:45
at MemberLink.App.iOS.Application.Main (System.String[] args) [0x00002] in c:\Projects\memberlink\App\MemberLink.App.iOS\Main.cs:37
2015-03-19 13:05:58.260 MemberLinkApp[886:353839] critical: Stacktrace:
2015-03-19 13:05:58.261 MemberLinkApp[886:353839] critical:
Native stacktrace:
2015-03-19 13:05:59.556 MemberLinkApp[886:353839] critical: 0 MemberLinkApp 0x02b940d1 mono_handle_native_sigsegv + 240
2015-03-19 13:05:59.557 MemberLinkApp[886:353839] critical: 1 MemberLinkApp 0x02b9947b sigabrt_signal_handler + 102
2015-03-19 13:05:59.558 MemberLinkApp[886:353839] critical: 2 libsystem_platform.dylib 0x30c8c0a3 _sigtramp + 42
2015-03-19 13:05:59.559 MemberLinkApp[886:353839] critical: 3 libsystem_pthread.dylib 0x30c91c97 pthread_kill + 62
2015-03-19 13:05:59.560 MemberLinkApp[886:353839] critical: 4 libsystem_c.dylib 0x30bb0939 abort + 76
2015-03-19 13:05:59.561 MemberLinkApp[886:353839] critical: 5 MemberLinkApp 0x02c56b68 fetch_virt_property + 0
2015-03-19 13:05:59.562 MemberLinkApp[886:353839] critical: 6 MemberLinkApp 0x02b94643 mono_invoke_unhandled_exception_hook + 66
2015-03-19 13:05:59.562 MemberLinkApp[886:353839] critical: 7 MemberLinkApp 0x02ba10ef mono_thread_abort_dummy + 62
2015-03-19 13:05:59.563 MemberLinkApp[886:353839] critical: 8 MemberL
inkApp 0x02b93d91 mono_handle_exception_internal + 3964
2015-03-19 13:05:59.564 MemberLinkApp[886:353839] critical: 9 MemberLinkApp 0x02b92e0f mono_handle_exception + 10
2015-03-19 13:05:59.565 MemberLinkApp[886:353839] critical: 10 MemberLinkApp 0x02b8ca93 mono_arm_throw_exception + 110
2015-03-19 13:05:59.566 MemberLinkApp[886:353839] critical: 11 MemberLinkApp 0x00f8a780 rethrow_exception + 68
2015-03-19 13:05:59.567 MemberLinkApp[886:353839] critical: 12 MemberLinkApp 0x00f2d5d4 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 200
2015-03-19 13:05:59.568 MemberLinkApp[886:353839] critical: 13 MemberLinkApp 0x02ba0893 mono_jit_runtime_invoke + 1162
2015-03-19 13:05:59.569 MemberLinkApp[886:353839] critical: 14 MemberLinkApp 0x02be8739 mono_runtime_invoke + 88
2015-03-19 13:05:59.570 MemberLinkApp[886:353839] critical: 15 MemberLinkApp 0x02bebc4b mono_runtime_exec_main + 282
2015-03-19 13:05:59.571 MemberLinkApp[886:353839] critical: 16 MemberLinkApp 0x02beba89 mono_runtime_run_main + 492
2015-03-19 13:05:59.571 MemberLinkApp[886:353839] critical: 17 MemberLinkApp 0x02b8a819 mono_jit_exec + 48
2015-03-19 13:05:59.572 MemberLinkApp[886:353839] critical: 18 MemberLinkApp 0x02c511bc xamarin_main + 2172
2015-03-19 13:05:59.573 MemberLinkApp[886:353839] critical: 19 MemberLinkApp 0x02b6d33d main + 108
2015-03-19 13:05:59.574 MemberLinkApp[886:353839] critical: 20 libdyld.dylib 0x30b4baaf <redacted> + 2
2015-03-19 13:05:59.575 MemberLinkApp[886:353839] critical:
================================
即使我启用了对所有异常的中断,它仍然不会中断,直到 Main。
我已经断定 HTTP 工作正常,因为登录功能工作顺利。在这一点上我对问题是什么一无所知,因为就像我说的,它在模拟器上工作正常。
OS & 软件信息:
- VS2013 SP4
- (Windows) Xamarin Studio 5.7.2(内部版本 7)
- (Mac) Xamarin Studio 5.8(内部版本 443)
- Xamarin.iOS 8.8.0.2
- Xamarin 构建主机 3.9.0.483
- Windows 8.1 Enterprise 运行 作为 Mac OS 上的并行虚拟机
Nuget 包:
- Newtonsoft.Json
- Microsoft.Net.Http
- Microsoft.Net.Async
- Microsoft.Bcl
- Fody & ProperyChanged.Fody(也确认它工作正常)
其他图书馆:
- Xamarin.iOS(统一API)
- MonoTouch.Dialog
其他技术:
- 故事板文件
- Nib (.xib) 文件
@Edit:经过进一步测试,我得出结论,当我在我的 UITabBarController
上设置 ViewControllers 属性 时会抛出此异常有史以来最奇怪的问题,但我想通了。
所以这很好用:
MyViewController : MvvmViewController<RandomViewModel>
但是,一旦我这样做:
EmbeddedViewController : MvvmViewController<RandomViewModel>
并在 Container View 中使用它(您只能通过设计器放置的控件,因为它在幕后做了一些魔术),它变得疯狂。而且不只是一点点,而是真的很生气。
所以我必须做的是直接从 UIViewController 继承,然后它起作用了。
我唯一能看到的应该是一个问题,就是我继承了一个带有泛型参数的 class,我们都知道 iOS 多么讨厌泛型。