简体   繁体   English

将WCF连接到Xamarin.Android项目时出现连接拒绝错误

[英]Connection refused error when connecting a WCF to a Xamarin.Android project

So I am new to Xamarin and WCF. 所以我是Xamarin和WCF的新手。 However, that wasn't gonna stop me from using those new technologies! 但是,这并不会阻止我使用这些新技术! Anyways, I started with this tutorial: https://docs.microsoft.com/en-us/xamarin/cross-platform/data-cloud/web-services/walkthrough-working-with-wcf 无论如何,我从本教程开始: https : //docs.microsoft.com/zh-cn/xamarin/cross-platform/data-cloud/web-services/walkthrough-working-with-wcf

I followed it step by step to no avail(numerous errors when building the project). 我一步一步地遵循了它,但是没有成功(在构建项目时出现许多错误)。 I then decided to use the sample code for the same tutorial provided here: https://developer.xamarin.com/samples/mobile/WCF-Walkthrough/ 然后,我决定将示例代码用于此处提供的同一教程: https : //developer.xamarin.com/samples/mobile/WCF-Walkthrough/

(click Download on the top right corner). (单击右上角的下载)。

When running this project (Android part), I get an error "Connection refused". 运行此项目(Android部分)时,出现错误“连接被拒绝”。 I'm guessing this is a generic error message that occurs even if the WCF wasn't even found (because I changed configurations to test that theory). 我猜测这是即使没有找到WCF也会发生的一般错误消息(因为我更改了配置以测试该理论)。

Can anyone help me solve this error? 谁能帮我解决这个错误?

Other things to note: 其他注意事项:

I have turned my firewall off (just in case). 我已关闭防火墙(以防万一)。 Based on the tutorial I did all of the IIS changes that were in there. 根据教程,我完成了其中所有的IIS更改。 I also made changes to the application.config file to have it contain my IP address. 我还对application.config文件进行了更改,以使其包含我的IP地址。 I have been stuck on this now for 3 days. 我已经坚持了三天。 It would be really useful to solve this error, because anyone else using that tutorial could also actually get the project working. 解决此错误将非常有用,因为使用该教程的其他任何人也实际上可以使项目正常工作。

Thanks In Advance! 提前致谢!

When you use the emulator, you cant just refer to LocalHost . 使用模拟器时,不能仅引用LocalHost The Localhost refers to the device on which the code is running, in this case the emulator. Localhost是指在其上运行代码的设备,在本例中为仿真器。

If you want to refer to the computer which is running the Android simulator, use the IP address 10.0.2.2 instead. 如果要引用运行Android模拟器的计算机,请改用IP地址10.0.2.2

More info here 更多信息在这里

Set up Android Emulator networking 设置Android模拟器网络

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM