c# – 如何从Xamarin.Forms中使用Azure Mobile Services?
发布时间:2020-12-15 18:10:38 所属栏目:百科 来源:网络整理
导读:我尝试从我简单的Forms应用程序使用Azure Mobile Services,它不起作用.最后一个命令永远运行.我检查了一个WebClient的互联网连接,没关系.该代码在简单的 Windows控制台应用程序中正常工作. var ms = new MobileServiceClient( @"https://xxx.azure-mobile.ne
我尝试从我简单的Forms应用程序使用Azure Mobile Services,它不起作用.最后一个命令永远运行.我检查了一个WebClient的互联网连接,没关系.该代码在简单的
Windows控制台应用程序中正常工作.
var ms = new MobileServiceClient( @"https://xxx.azure-mobile.net/",@"xxx" ); IMobileServiceTable<TodoItem> todoTable = ms.GetTable<TodoItem>(); List<TodoItem> items = todoTable .Where(todoItem => todoItem.Complete == false).ToListAsync().Result; 编辑: Java.Lang.RuntimeException: java.lang.reflect.InvocationTargetException at --- End of managed exception stack trace --- at java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:675) at at dalvik.system.NativeStart.main(Native Method) at Caused by: java.lang.reflect.InvocationTargetException at at java.lang.reflect.Method.invokeNative(Native Method) at at java.lang.reflect.Method.invoke(Method.java:515) at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:859) at ... 2 more at Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object at at Xamarin.Forms.Platform.Android.FormsApplicationActivity.OnPrepareOptionsMenu (Android.Views.IMenu) <IL 0x00007,0x00050> at Android.App.Activity.n_OnPrepareOptionsMenu_Landroid_view_Menu_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d23da369/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.App.Activity.cs:4151 at at (wrapper dynamic-method) object.fcd55d8e-49be-4c8f-b3a6-37be6bdb988f (intptr,intptr) <IL 0x00017,0x0005b> at at md5530bd51e982e6e7b340b73e88efe666e.FormsApplicationActivity.n_onPrepareOptionsMenu(Native Method) at at md5530bd51e982e6e7b340b73e88efe666e.FormsApplicationActivity.onPrepareOptionsMenu(FormsApplicationActivity.java:110) at at android.app.Activity.onPreparePanel(Activity.java:2612) at at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:518) at at com.android.internal.policy.impl.PhoneWindow.doInvalidatePanelMenu(PhoneWindow.java:872) at at com.android.internal.policy.impl.PhoneWindow$1.run(PhoneWindow.java:243) at at android.view.Choreographer$CallbackRecord.run(Choreographer.java:780) at at android.view.Choreographer.doCallbacks(Choreographer.java:593) at at android.view.Choreographer.doFrame(Choreographer.java:561) at at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:766) at at android.os.Handler.handleCallback(Handler.java:733) at at android.os.Handler.dispatchMessage(Handler.java:95) at at android.os.Looper.loop(Looper.java:136) at at android.app.ActivityThread.main(ActivityThread.java:5290) at ... 5 more 解决方法
你确定你没有阻止你的UI与组合的async / await(死锁)?
修改你的代码如下: IMobileServiceTable<TodoItem> todoTable = await ms.GetTable<TodoItem>(); List<TodoItem> items = todoTable.Where(todoItem => todoItem.Complete == false).ToListAsync().ConfigureAwait(false); 有关此特定问题的更多信息:http://blog.stephencleary.com/2012/07/dont-block-on-async-code.html 有关僵局的进一步信息,Stephen Clary有一个很好的博客:http://blog.stephencleary.com/2012/02/async-and-await.html (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |