Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从Android emulator连接到本地主机上的wcf服务时遇到问题_C#_Android_Wcf_Iis_Iis Express - Fatal编程技术网

C# 从Android emulator连接到本地主机上的wcf服务时遇到问题

C# 从Android emulator连接到本地主机上的wcf服务时遇到问题,c#,android,wcf,iis,iis-express,C#,Android,Wcf,Iis,Iis Express,我正在用Xamarin Studio构建一个应用程序,它应该可以访问wcf服务。使用以下url从我的浏览器访问服务可以正常工作: http://localhost:52277/api 每当我尝试从android代码访问它时,我都会遇到以下异常: System.Net.WebException: Error: ConnectFailure (Connection refused) ---> System.Exception: Connection refused at System.Ne

我正在用Xamarin Studio构建一个应用程序,它应该可以访问wcf服务。使用以下url从我的浏览器访问服务可以正常工作:
http://localhost:52277/api

每当我尝试从android代码访问它时,我都会遇到以下异常:

System.Net.WebException: Error: ConnectFailure (Connection refused) ---> System.Exception: Connection refused
  at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in <filename unknown>:0
  at System.Net.WebConnection.Connect (System.Net.HttpWebRequest request) [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
  at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0
  at ServiceStack.ServiceClient.Web.ServiceClientBase.Send[String] (System.String httpMethod, System.String relativeOrAbsoluteUrl, System.Object request) [0x00051] in c:\Users\nicklas.winger\Documents\GitHub\ServiceStack\src\ServiceStack.Common\ServiceClient.Web\ServiceClientBase.cs:896
System.Net.WebException:错误:ConnectFailure(连接被拒绝)--->System.Exception:连接被拒绝
在:0中的System.Net.Sockets.Socket.Connect(System.Net.EndPoint remoteEP)[0x00000]处
0中的System.Net.WebConnection.Connect(System.Net.HttpWebRequest请求)[0x00000]处
---内部异常堆栈跟踪的结束---
0中的System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)[0x00000]处
位于:0中的System.Net.HttpWebRequest.GetResponse()[0x00000]
在c:\Users\nicklas.winger\Documents\GitHub\ServiceStack\src\ServiceStack.Common\ServiceClient.Web\ServiceClientBase中的ServiceStack.ServiceClient.Web.ServiceClientBase.Send[String](System.String httpMethod,System.String relativeorabsoluteur,System.Object request)[0x00051]处
我正在IIS express上运行该服务,并且我已经修改了我的IIS applicationhost.config,如下所示(根据pluralsight上的课程,从bindingInformation中删除“localhost”):


此外,我的web服务正在上述端口上使用iis express构建和部署。
对我可能做错了什么有什么建议吗?:)

通过使用以下ip解决:
10.0.2.2而不是本地主机。

请查看@NicklasWinger注意:ServiceStack客户端仅用于消费ServiceStack服务,而不是WCF。我还解决了更改我的Web服务ip的本地主机的问题。谢谢:)我从没想过这会奏效。但是我怎么知道呢?这是你电脑的ip还是android模拟器?你在哪里换的?谢谢,我当时会用我的电脑。有点模糊,因为这篇文章大约有4年了:/
<site name="ProteinTrackerMvc" id="45">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="c:\users\nicklas.winger\documents\visual studio 2012\Projects\ProteinTrackerMvc\ProteinTrackerMvc" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:52277:" />
    </bindings>
</site>