System.Net.Http

时间:2017-01-18 07:21:28

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

我有这个例外,我在我的日志中打印导致应用程序在android,motorola device xt1058中崩溃。

问题是我没有设备,而是从发送给我日志文件的客户端获取日志。

我不知道日志的来源。

我将所有应用程序包装在try catch中,但应用程序仍然崩溃了

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

09:37:11 - TaskSchedulerOnUnobservedTaskException出错:System.AggregateException:通过等待任务或访问其Exception属性未观察到任务的异常。结果,终结器线程重新抛出了未观察到的异常。 ---&GT; System.Net.WebException:错误:NameResolutionFailure   在System.Net.HttpWebRequest.EndGetResponse(System.IAsyncResult asyncResult)[0x00064] in&lt; 552eeeb8705c4abb9eeb5ebce43b6865&gt ;:0   at System.Threading.Tasks.TaskFactory 1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func 2 [T,TResult] endFunction,System.Action 1[T] endAction, System.Threading.Tasks.Task 1 [TResult] promise,System.Boolean requiresSynchronization)[0x00014] in&lt; 52ca43e23d764403a7855ae066156266&gt ;:0 ---从抛出异常的先前位置开始的堆栈跟踪结束---   在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()[0x0000c] in&lt; 52ca43e23d764403a7855ae066156266&gt ;:0   在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task任务)[0x0004e] in&lt; 52ca43e23d764403a7855ae066156266&gt ;:0   在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task任务)[0x0002e] in&lt; 52ca43e23d764403a7855ae066156266&gt ;:0   在System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(System.Threading.Tasks.Task任务)[0x0000b] in&lt; 52ca43e23d764403a7855ae066156266&gt ;:0   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable 1+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.ConfiguredTaskAwaitable 1 + ConfiguredTaskAwaiter [TResult] .GetResult()[0x00000] in&lt; 52ca43e23d764403a7855ae066156266&gt ;:0   在System.Net.Http.HttpClient + c__async0.MoveNext()[0x000f3] in&lt; 21d260c0947046f0aae7990757a51ba3&gt ;:0    ---内部异常堆栈跟踪结束--- ---&GT; (内部异常#0)System.Net.WebException:错误:NameResolutionFailure   在System.Net.HttpWebRequest.EndGetResponse(System.IAsyncResult asyncResult)[0x00064] in&lt; 552eeeb8705c4abb9eeb5ebce43b6865&gt ;:0   at System.Threading.Tasks.TaskFactory 1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func 2 [T,TResult] endFunction,System.Action 1[T] endAction, System.Threading.Tasks.Task 1 [TResult] promise,System.Boolean requiresSynchronization)[0x00014] in&lt; 52ca43e23d764403a7855ae066156266&gt ;:0 ---从抛出异常的先前位置开始的堆栈跟踪结束---   在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()[0x0000c] in&lt; 52ca43e23d764403a7855ae066156266&gt ;:0   在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task任务)[0x0004e] in&lt; 52ca43e23d764403a7855ae066156266&gt ;:0   在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task任务)[0x0002e] in&lt; 52ca43e23d764403a7855ae066156266&gt ;:0   在System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(System.Threading.Tasks.Task任务)[0x0000b] in&lt; 52ca43e23d764403a7855ae066156266&gt ;:0   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable 1+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.ConfiguredTaskAwaitable 1 + ConfiguredTaskAwaiter [TResult] .GetResult()[0x00000] in&lt; 52ca43e23d764403a7855ae066156266&gt ;:0   在System.Net.Http.HttpClient + c__async0.MoveNext()[0x000f3] in&lt; 21d260c0947046f0aae7990757a51ba3&gt ;:0&lt; ---

1 个答案:

答案 0 :(得分:0)

问题在于http call导致您出现此错误,因此如果返回您期望的内容,请在Postman扩展上交叉检查您的API。检查您的网站是否正在运行,检查网络状态,并且请习惯通过try和catch来围绕这些呼叫。

使用try catch将所有http呼叫包围起来后,将调试器置于catch语句中,了解exception并验证相同的网址。