Xamarin.Forms - ' jobject'不能是PushAsync上的IntPtr.Zero

时间:2015-10-19 11:24:45

标签: xamarin xamarin.android xamarin.forms

有人知道在将我的Xamarin Forms从1.4升级到1.5后,我收到此错误:

System.ArgumentException:' jobject'不能是IntPtr.Zero

完整堆栈错误:

10-19 06:47:47.893 D/Mono    ( 3675): Searching for '__android_log_print'.
10-19 06:47:47.896 I/MonoDroid( 3675): at Android.Views.ActionMode/ICallbackInvoker.n_OnActionItemClicked_Landroid_view_ActionMode_Landroid_view_MenuItem_ (intptr,intpt10-19 06:47:47.893 D/Mono    ( 3675): Probing '__android_log_print'.
10-19 06:47:47.893 D/Mono    ( 3675): Found as '__android_log_print'.
10-19 06:47:47.894 I/MonoDroid( 3675): UNHANDLED EXCEPTION:
10-19 06:47:47.896 I/MonoDroid( 3675): System.ArgumentException: 'jobject' must not be IntPtr.Zero.
10-19 06:47:47.896 I/MonoDroid( 3675): Parameter name: jobject
10-19 06:47:47.896 I/MonoDroid( 3675): at Android.Runtime.JNIEnv.CallVoidMethod (intptr,intptr) [0x00010] in /Users/builder/data/lanes/2058/58099c53/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:546
10-19 06:47:47.896 I/MonoDroid( 3675): at Android.Views.ActionModeInvoker.Finish () [0x0002d] in /Users/builder/data/lanes/2058/58099c53/source/monodroid/src/Mono.Android/platforms/android-22/src/generated/Android.Views.ActionMode.cs:804
10-19 06:47:47.896 I/MonoDroid( 3675): at Xamarin.Forms.Platform.Android.CellAdapter.OnActionItemClicked (Android.Views.ActionMode,Android.Views.IMenuItem) <IL 0x00008, 0x00044>
10-19 06:47:47.896 I/MonoDroid( 3675): at Android.Views.ActionMode/ICallbackInvoker.n_OnActionItemClicked_Landroid_view_ActionMode_Landroid_view_MenuItem_ (intptr,intptr,intptr,intptr) [0x00019] in /Users/builder/data/lanes/2058/58099c53/source/monodroid/src/Mono.Android/platforms/android-22/src/generated/Android.Views.ActionMode.cs:89
10-19 06:47:47.896 I/MonoDroid( 3675): at (wrapper dynamic-method) object.ecb01028-fd89-41d7-b184-af818f2dde3e (intptr,intptr,intptr,intptr) <IL 0x0001d, 0x00037>
10-19 06:47:47.899 W/art     ( 3675): JNI RegisterNativeMethods: attempt to register 0 native methods for md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable
10-19 06:47:47.900 D/AndroidRuntime( 3675): Shutting down VM

当我尝试这样做时会出现:

await App.MyTabbedPageMenu.orderNavigationPage.PushAsync(new DetalhesPedidoView(webPedidoModel));

仅在Android上出现在IOS上,一切正常。

感谢

2 个答案:

答案 0 :(得分:2)

感谢Xamarin论坛的Torben Kruse回答问题并解决了问题

await Task.Yield()
在推送页面之前

更多信息:https://forums.xamarin.com/discussion/54112/jobject-must-not-be-intptr-zero-on-pushasync

答案 1 :(得分:0)

await Task.Yield()是一个选项,有时它不起作用,在我的情况下,它收集垃圾后解决

GC.collect();