【问题标题】:exception in xamarin.forms in System.Net.HttpSystem.Net.Http 中的 xamarin.forms 异常
【发布时间】:2017-01-18 07:21:28
【问题描述】:

我在日志中打印了这个异常,导致应用在 android、摩托罗拉设备 xt1058 中崩溃。

问题是我没有设备,我从向我发送日志文件的客户那里得到了日志。

我不知道日志来自哪里。

我已将所有应用程序都包裹在 try catch 中,但应用程序仍然崩溃

09:37:10 - TaskSchedulerOnUnobservedTaskException 中的错误: 通过等待任务或访问其异常属性未观察到任务的异常。结果,未观察到的异常被终结器线程重新抛出。

09:37:11 - TaskSchedulerOnUnobservedTaskException 中的错误:System.AggregateException:通过等待任务或访问其异常属性未观察到任务的异常。结果,未观察到的异常被终结器线程重新抛出。 ---> System.Net.WebException:错误:NameResolutionFailure 在 System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x00064] 在 :0 在 System.Threading.Tasks.TaskFactory1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func2[T,TResult] endFunction, System.Action1[T] endAction, System.Threading.Tasks.Task1[TResult] promise, System.Boolean requiresSynchronization) [0x00014] in :0 --- 从先前抛出异常的位置结束堆栈跟踪 --- 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] 在 :0 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task 任务) [0x0004e] 在 :0 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task 任务) [0x0002e] 在 :0 在 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task 任务) [0x0000b] 在 :0 在 System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <52ca43e23d764403a7855ae066156266>:0 at System.Net.Http.HttpClientHandler+<SendAsync>c__async0.MoveNext () [0x0041e] in <21d260c0947046f0aae7990757a51ba3>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <52ca43e23d764403a7855ae066156266>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <52ca43e23d764403a7855ae066156266>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <52ca43e23d764403a7855ae066156266>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <52ca43e23d764403a7855ae066156266>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] 在 :0 在 System.Net.Http.HttpClient+c__async0.MoveNext () [0x000f3] 在 :0 --- 内部异常堆栈跟踪结束 --- --->(内部异常#0)System.Net.WebException:错误:NameResolutionFailure 在 System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x00064] 在 :0 在 System.Threading.Tasks.TaskFactory1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func2[T,TResult] endFunction, System.Action1[T] endAction, System.Threading.Tasks.Task1[TResult] promise, System.Boolean requiresSynchronization) [0x00014] in :0 --- 从先前抛出异常的位置结束堆栈跟踪 --- 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] 在 :0 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task 任务) [0x0004e] 在 :0 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task 任务) [0x0002e] 在 :0 在 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task 任务) [0x0000b] 在 :0 在 System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <52ca43e23d764403a7855ae066156266>:0 at System.Net.Http.HttpClientHandler+<SendAsync>c__async0.MoveNext () [0x0041e] in <21d260c0947046f0aae7990757a51ba3>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <52ca43e23d764403a7855ae066156266>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <52ca43e23d764403a7855ae066156266>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <52ca43e23d764403a7855ae066156266>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <52ca43e23d764403a7855ae066156266>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] 在 :0 在 System.Net.Http.HttpClient+c__async0.MoveNext () [0x000f3] 在 :0

【问题讨论】:

  • 是名称解析失败吗?什么时候崩溃的?
  • 不幸的是,这是我仅有的详细信息 - 我不知道它何时崩溃,因为我有几个使用 system.net.http 的任务和服务
  • 等待你的异步调用,这至少会给你一个有意义的例外。

标签: xamarin.android xamarin.forms system.net


【解决方案1】:

问题在于http call 之一导致您出现此错误,因此请在 Postman 扩展上交叉检查您的 API,如果它返回您所期望的。检查您的网站是否正在运行,检查网络状态,请养成使用 try 和 catch 包围这些调用的习惯。

try catch 包围所有http 调用后,将调试器放入catch 语句,了解exception 并验证相同的URL。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-18
    • 2014-11-06
    • 1970-01-01
    • 1970-01-01
    • 2019-01-22
    • 1970-01-01
    相关资源
    最近更新 更多