Xamarin System.Net.WebException缺少WebExceptionStatus.NameResolutionFailure [英] Xamarin System.Net.WebException missing WebExceptionStatus.NameResolutionFailure

查看:363
本文介绍了Xamarin System.Net.WebException缺少WebExceptionStatus.NameResolutionFailure的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于 WebExceptionStatus Xamarin.Forms 中无法正确处理>枚举,即 NameResolutionFailure 成员。

I have an exception I can't handle properly in Xamarin.Forms due to a missing member in the WebExceptionStatus enumeration, namely the NameResolutionFailure member.

有人知道如何在这种特定情况下正确处理异常吗?

Does anyone know how I can properly handle the exception in this specific case?

推荐答案

查看以前版本的 WebExceptionStatus 枚举,PCL不支持 NameResolutionFailure 成员。

解决此问题的方法如下:

What you can do to handle this issue is as follows:

case (System.Net.WebExceptionStatus)1:
    // your code

或:

catch (System.Net.WebException ex)
{
    if ((int)ex.Status == 1)
        // your code
)

我通过简单地抛出一个新的 WebException 进行了测试:

I tested this by simply throwing a new WebException like this:

throw new System.Net.WebException("Test", (System.Net.WebExceptionStatus)1);

我认为哪个返回了 NameResolutionFailure StatusCode

这篇关于Xamarin System.Net.WebException缺少WebExceptionStatus.NameResolutionFailure的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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