尝试/捕获不适用于带有Azure移动服务的WP8 C#.NET [英] Try/Catch not working for WP8 C# .NET with Azure Mobile Services

查看:51
本文介绍了尝试/捕获不适用于带有Azure移动服务的WP8 C#.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在玩这段代码:

 try
 {
   mscvUser = imstUser
    .Where(User => User.Id == intId)
    .Take(1000)
    .ToCollectionView();
 }
 catch(MobileServiceInvalidOperationException f){

  MessageBox.Show(f.ToString());

 }

它通常可以正常工作,但是出于测试目的,我故意断开了Internet的连接,并且我一直遇到MobileServiceInvalidOperationException,但是在该代码块中它不会被捕获;它将其返回给App.xaml.cs,中断并关闭该应用.

It works fine normally, but I've been deliberately disconnecting my Internet for testing purposes, and I keep hitting MobileServiceInvalidOperationException, but it won't catch it in that block; it throws it back to App.xaml.cs, breaks, and shuts down the app.

推荐答案

我认为您没有使用最新版本的Azure移动服务.该SDK最近更新至版本1.0: http://nuget.org/packages/WindowsAzure.MobileServices/

I think you are not using the newest version of Azure Mobile Services. The SDK was recently updated to version 1.0: http://nuget.org/packages/WindowsAzure.MobileServices/

我检查了此版本,并正确捕获了异常.

I checked with this version and the exception is catched correctly.

在最新版本中,"ToCollectionView"已被替换,您现在必须使用

In the newest version, "ToCollectionView" was replaced and you'd now have to use

try
 {
   mscvUser = await imstUser
    .Where(User => User.Id == intId)
    .Take(1000)
    .ToCollectionAsync();
 }
 catch(MobileServiceInvalidOperationException f){

  MessageBox.Show(f.ToString());

 }

希望这会有所帮助

来自变更日志:

MobileServiceTable.ToCollectionView()现在是ToCollection():集合视图实现存在一些错误,并且已被重写.

MobileServiceTable.ToCollectionView() is now ToCollection(): the collection view implementation had some bugs, and it has been rewritten.

您可以在此处阅读

这篇关于尝试/捕获不适用于带有Azure移动服务的WP8 C#.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆