问题描述
当我的应用遇到连接问题时,它突然崩溃并且没有引发异常。我已经放了Microsoft App Center插件,这是当机报告:
Xamarin Exception Stack:
System.NullReferenceException: Object reference not set to an instance of an object
at Project.XAML.AtendimentosUser.GetData (System.Collections.Specialized.NameValueCollection data) [0x000f3] in <8ee15104665a463180bbffb742ed9570>:0
at System.Runtime.CompilerServices.AsyncmethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in <0db975f2d36842718f4da4da36d2fcb7>:0
at Android.App.SyncContext+<>c__displayClass2_0.<Post>b__0 () [0x00000] in <c2957c7ec1ac46f688b7f30f24232572>:0
at java.lang.Thread+RunnableImplementor.Run () [0x00008] in <c2957c7ec1ac46f688b7f30f24232572>:0
at java.lang.IRunnableInvoker.n_Run (system.intPtr jnienv,system.intPtr native__this) [0x00008] in <c2957c7ec1ac46f688b7f30f24232572>:0
at (wrapper dynamic-method) Android.Runtime.DynamicmethodNameCounter.35(intptr,intptr)
AtendimentosUser.GetData方法的代码:
async void GetData(NameValueCollection data)
{
/* try { */
StackListagem.IsVisible = false;
SemResultados.IsVisible = false;
LoadingItems.IsRunning = true;
LoadingContainer.IsVisible = true;
WebService client = new WebService();
agendamentos = await Task.Run(() => client.PostData<List<Agendamento>>(url,data,debug: true));
LoadingContainer.IsVisible = false;
LoadingItems.IsRunning = false;
if (agendamentos.Count > 0)
{
LabelListagem.Text = "Você tem " + agendamentos.Count + " agendamento(s) para " + ((Mes)PickerMes.SelectedItem).label + " de " + PickerAno.SelectedItem;
ListagemAgendamento.ItemsSource = agendamentos;
StackListagem.IsVisible = true;
}
else
{
CaptionTxt.Text = "Você não possui agendamentos" + Environment.NewLine + " para " + ((Mes)PickerMes.SelectedItem).label + " de " + PickerAno.SelectedItem;
SemResultados.IsVisible = true;
}
/* } catch { GetData(data); } */
}
我刚刚添加了try / catch,但是我不知道这样是否可以正确处理问题。
你们看到导致此问题的原因了吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)