Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.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
Visual studio Visual Studio:无法从我的xamarin android项目连接到azure mobile项目_Visual Studio_Xamarin.android_Samsung Mobile - Fatal编程技术网

Visual studio Visual Studio:无法从我的xamarin android项目连接到azure mobile项目

Visual studio Visual Studio:无法从我的xamarin android项目连接到azure mobile项目,visual-studio,xamarin.android,samsung-mobile,Visual Studio,Xamarin.android,Samsung Mobile,在我的visual studio解决方案中,我有两个项目: 沙马林机器人 Azure移动服务 我不是在使用模拟器,我是在用我的android手机进行测试 当我键入http://localhost:55492/tables/todoitem在浏览器的地址栏中,我获得了示例数据: [ {"id":"784034d4-076c-4bbd-8ec0-72d3c1993c50","complete":false,"text":"First item"}, {"id":"ae90715d-063b-

在我的visual studio解决方案中,我有两个项目:

  • 沙马林机器人
  • Azure移动服务
我不是在使用模拟器,我是在用我的android手机进行测试

当我键入
http://localhost:55492/tables/todoitem
在浏览器的地址栏中,我获得了示例数据:

[
 {"id":"784034d4-076c-4bbd-8ec0-72d3c1993c50","complete":false,"text":"First item"},
 {"id":"ae90715d-063b-44b2-916e-97ca8082d436","complete":false,"text":"Second item"}
]
我在主活动中添加了这一行:

//...
Button button = FindViewById<Button>(Resource.Id.MyButton);

using (WebClient client = new WebClient())
{
  byte[] arr = client.DownloadData("http://localhost:55492/tables/todoitem");
  //...
}
/。。。
Button Button=FindViewById(Resource.Id.MyButton);
使用(WebClient=newWebClient())
{
字节[]arr=客户端下载数据(“http://localhost:55492/tables/todoitem");
//...
}
我收到以下错误:未处理的异常。System.Net.WebException:错误:连接失败(连接被拒绝)

是否有任何理由拒绝连接


感谢您的帮助

您需要在服务器URL中使用PC的IP地址,而不是本地主机。使用localhost将导致手机尝试连接到自身。您可以通过打开控制台并在Windows上运行ipconfig和在大多数其他平台上运行ifconfig来获取IP地址。

我已将localhost替换为IP地址,如下所示:
http://10.0.0.4:55492/tables/todoitem
。现在我收到了一个
超时异常
。您的手机是否与PC连接到同一网络?通过USB连接android手机不会将它们连接到同一网络,它们也必须通过wifi连接。你打开电脑防火墙上的端口了吗?我已打开防火墙上的端口,并将手机连接到wifi。现在我得到:
System.Net.WebException:远程服务器返回了一个错误:(400)请求错误。
这表明至少您正在访问后端。我意识到的另一件事是,你不能从远程机器上点击IIS Express。尝试在完整的IIS上运行站点。现在我正在运行完整的IIS。但是我现在遇到了这个错误:
error:ConnectFailure(连接被拒绝)