【问题标题】:System.Net.WebException: Error: NameResolutionFailure when Calling WCF Services throwing exception in mono android applicationSystem.Net.WebException:错误:NameResolutionFailure 调用 WCF 服务时在单声道 android 应用程序中抛出异常
【发布时间】:2013-08-02 11:30:52
【问题描述】:

我正在开发 Mono Android Mobile 应用程序。我在我的应用程序中调用我的 WCF 服务,我使用项目菜单的 -> 添加 WebRefernce 选项添加了 wcf 服务。我的问题是当我在设备上运行调用 wcf 服务时出现异常。

例外

{System.Net.WebException: 错误: NameResolutionFailure at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult) [0x00000] in :0

在 System.Net.HttpWebRequest.GetRequestStream()[0x00000] 中 :0 在 System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke (System.String method_name, System.Object[] 参数) [0x00000] in :0 }

我的设备有互联网连接,使用 WiFi 连接来获取和发布数据

另一种方式

我尝试使用移动数据使用网络连接调用服务,即使用移动网络提供商的互联网连接..这次我遇到了一个不同的例外..

{System.Net.WebException:请求失败,HTTP 状态 404: 未找到 System.Web.Services.Protocols.SoapHttpClientProtocol.ReceiveResponse (System.Net.WebResponse 响应, System.Web.Services.Protocols.SoapClientMessage 消息, System.Web.Services.Protocols.SoapExtension[] 扩展)[0x00000] 在 :0 在 System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke (System.String method_name, System.Object[] 参数) [0x00000] in :0 在 AndroidWCFExample.WirelessService.SAGServer.ProcessSomeUpdate (AndroidWCFExample.WirelessService.WebServicesClient oClientInfo, System.String ParameterInfo) [0x00001] 在 C:\Some Dotnet 示例\AndroidWCFExample\AndroidWCFExample\Web References\WirelessService\Reference.cs:1232 at (wrapper 远程调用检查) AndroidWCFExample.WirelessService.SAGServer:ProcessSomeUpdate (AndroidWCFExample.WirelessService.WebServicesClient,字符串)在 AndroidWCFExample.EmployeeInfoActivity.button_Click (System.Object 发件人,System.EventArgs e) [0x0007a] 在 C:\Some Dotnet 示例\AndroidWCFExample\AndroidWCFExample\EmployeeInfoActivity.cs:79 }

我正在寻找解决方案来解决这个问题,但没有得到正确的答案。 所以请让我知道我需要做什么来修复它。请帮帮我。

当我在 android 模拟器上运行应用程序时,这可以正常工作

在此先感谢.. 斯里尼

【问题讨论】:

  • 如果没有代码,您希望如何帮助您?

标签: android .net wcf mono xamarin.android


【解决方案1】:

为您的应用设置 Internet 权限,并确保您的设备已连接到 Internet。

【讨论】:

    【解决方案2】:

    我知道这是一个旧帖子,但遇到了同样的错误,所以想分享解决方案。

    1. 我找到的最佳解决方案是,当 Wifi 发生异常时 已连接,只是为了重试我的服务器调用并稍微休眠 之间。它大部分时间都有效,否则如果第二次调用 失败我取消请求。
    2. 如果用户的 Wifi 非常不稳定或 信号非常低。如果没有互联网也会出现同样的错误 完全连接,即使连接到 Wifi。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-05
      • 1970-01-01
      • 2016-03-21
      • 1970-01-01
      • 1970-01-01
      • 2011-09-24
      • 2010-12-11
      • 2021-09-17
      相关资源
      最近更新 更多