Firebase.Database.FirebaseException:处理请求时发生异常 [英] Firebase.Database.FirebaseException: Exception occured while processing the request

查看:43
本文介绍了Firebase.Database.FirebaseException:处理请求时发生异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

未处理的异常:Firebase.Database.FirebaseException:异常处理请求时发生.网址:https://mylimo-b2029.firebaseio.com/users/.json 请求数据:响应:{"first_name":"dsadas"} 发生

Unhandled Exception: Firebase.Database.FirebaseException: Exception occured while processing the request. Url: https://mylimo-b2029.firebaseio.com/users/.json Request Data: Response: {"first_name":"dsadas"} occurred

Mainpage.xaml.cs:

 protected async override void OnAppearing()
    {

      base.OnAppearing();
       var allUsers = await firebaseHelper.GetAllUsers();
       lstPersons.ItemsSource = allUsers;
   }

Firebasehelper.cs:

public async Task<List<Users>> GetAllUsers()
    {

        return (await firebase
          .Child("users")

          .OnceAsync<Users>()).Select(item => new Users
          {
              //user_id = item.Object.user_id,
              first_name = item.Object.first_name
          }).ToList();
    }

推荐答案

我遇到了同样的问题,决定检查是否所有属性都设置了我的本地对象.只是验证属性是否为空,没有解析.

I had the same problem and decided to check if all properties are setting my local object. Just validating if the property is null, did not resolve.

之前:

var item = await firebase.Child("users").OnceAsync <Users> ());

那么:

using Newtonsoft.Json.Linq;

var item = await firebase.Child("users").OnceAsync <JObject> ());

问题出在反序列化上.您可以使用以下命令访问 JObject 中的属性:

The problem is in the deserialization. You can access the properties in the JObject with:

var itemProperty = item.Object.GetValue("<property_name>").

这篇关于Firebase.Database.FirebaseException:处理请求时发生异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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