在Xamarin Forms应用程序中使用文件同步后立即获取服务器错误(500) [英] Getting a server error (500) as soon as File Sync is used in Xamarin Forms app

查看:118
本文介绍了在Xamarin Forms应用程序中使用文件同步后立即获取服务器错误(500)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例源代码:

https://drive.google.com/file/d/0BzYXG8uD6JT3ai1SN3lfRE5oNWs/view

背景:

使用Azure应用服务作为后端,通过Azure数据同步创建Xamarin Forms应用.在Azure上使用基于Dot Net的托管后端.

Creating a Xamarin Forms app with Azure Data Sync with Azure app Services as backend. Using Dot Net based Managed backend on azure.

我的问题:

我的应用在离线模式下可以正常运行&我可以单击同步"以将所有脱机数据同步到azure.

My app works fine in offline mode & I can click on sync to sync all offline data to azure.

如果现在我还需要合并文件同步功能,以便可以在离线模式下使用我的应用程序中的文件&还可以将它们同步到天蓝色,我可以使用Azure File Sync.我正在按照此处给出的步骤进行操作:

If now I need to also incorporate File Syncing so I can use files in my app in offline mode & also sync them to azure, I can use Azure File Sync. I am following the steps given here:

https://azure.microsoft.com/zh-CN/documentation/articles/app-service-mobile-xamarin-forms-blob-storage/

在所附的示例代码中,如果您在AzureHelper.cs中的第44、46和第29行注释了文件同步相关的代码. 74,取消注释第41行的数据同步呼叫,它按预期工作.

In the attached sample code, If you comment the file sync related code in AzureHelper.cs at line numbers 44, 46 & 74 and uncomment the data sync call at Line number 41 it works as expected.

如果您现在注释第41行和第取消注释同一文件中44、46、74处用于文件同步的代码&运行代码,您将收到500错误.此外,这500个错误在Visual Studio的Box中显示为一个未经处理的异常,在这里我在所有可能的错误位置使用了catch块.因此,捕获此错误的来源变得异常困难.

If you now comment the code on Line Number 41 & uncomment the code for for File Sync at 44, 46, 74 in the same file & run the code, you get a 500 error. Moreover this 500 error is shown in a Box in Visual Studio as an unhandlled exception, where as I have catch block used at all possible erroneous locations. Because of this it has become incredibly difficult to catch the source of this error.

这就是让我相信错误发生在文件同步更改中的原因,只是无法确定是什么块?

This is what led me to believe that the error is somewhere in File Sync changes, just can't figure out what block?

有人可以阐明这一点吗?

Can someone please shed some light on this?

谢谢 ST

推荐答案

您需要为所有对象创建存储控制器,或者修改

Either you need to create storage controller for all, or modify the

public sealed class ReportSwiftEntityDataFileSyncTrigger : IFileSyncTrigger, IDisposable
{
private async void OnStoreOperationCompleted(StoreOperationCompletedEvent storeOperationEvent)
        {
            if (storeOperationEvent.Operation.TableName!="Report")
            {
                return; 
            }
        }
}

如图所示的

class忽略了类名不是您需要使用存储控制器的任何情况.

class as shown to ignore any cases where class name is not where you need to use the storage controller.

希望这会有所帮助.

这篇关于在Xamarin Forms应用程序中使用文件同步后立即获取服务器错误(500)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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