Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Try/Catch不适用于使用Azure移动服务的WP8 C#.NET_C#_.net_Windows Phone 8_Azure Mobile Services - Fatal编程技术网

Try/Catch不适用于使用Azure移动服务的WP8 C#.NET

Try/Catch不适用于使用Azure移动服务的WP8 C#.NET,c#,.net,windows-phone-8,azure-mobile-services,C#,.net,Windows Phone 8,Azure Mobile Services,我在玩这段代码: try { mscvUser = imstUser .Where(User => User.Id == intId) .Take(1000) .ToCollectionView(); } catch(MobileServiceInvalidOperationException f){ MessageBox.Show(f.ToString()); } 它工作正常,但我一直故意断开我的互联网进行测试,我不断点击MobileSe

我在玩这段代码:

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

  MessageBox.Show(f.ToString());

 }

它工作正常,但我一直故意断开我的互联网进行测试,我不断点击MobileServiceInvalidOperationException,但它不会捕捉到它在该块中;它会将其返回App.xaml.cs,中断并关闭该应用。

我认为您没有使用最新版本的Azure移动服务。SDK最近更新为1.0版:

我检查了这个版本,异常被正确捕获

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

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

  MessageBox.Show(f.ToString());

 }
希望这有帮助

编辑: 此处来自变更日志:

MobileServiceTable.ToCollectionView()现在是ToCollection():collection视图实现有一些错误,已被重写


尝试捕获
异常
,找出真正的类型,并确保上面捕获的
异常
也执行相同的操作。我使用的是1.0,不必收集异步()。奇怪,我刚登记了一个新项目。仅ToCollectionAsync()可用作扩展方法,这意味着您需要使用Microsoft.WindowsAzure.MobileServices的using语句
我建议您尝试重新安装sdk。我以前在nuget上遇到过问题。好吧,我发现了问题,很明显,尽管安装了新的MobileServices,我还是以某种方式使用了旧的MobileServices。我现在才有一个新的,我现在需要回去改变很多事情来让它工作。我会在一切完成后报告。我遇到了另一个问题,MobileServiceTableSerializer在1.0中不再存在。它现在似乎都在工作,谢谢。其他用户应该警惕1.0中的更改。