(附加:我认为如果我在本地主机可以工作的同一台计算机上使用模拟器)
嗨,我已经用谷歌搜索并查看了几个小时的视频,看到他们成功了,但我无法让它工作。
我注意到您无法从 Xamarin.Android 直接连接到外部 SqlDB 您必须为此解决方案制作自己的网络服务。
我已经创建了一个网络服务,并且只留下了返回字符串的 helloworld()。
public string HelloWorld()
{
return "Hello World";
}
并且 Xamarin.Android 需要将它放在 IIS express 无法访问的 IIS 上。检查我在那里有它,然后我进入 IIS 并测试它,它出现并且运行良好。我从中得到了 WDSL
http://localhost/Webservicedemo/Connector.asmx?WSDL
然后我进入我的 Xamarin.Android 项目并尝试展示它。我已经在 Xamarin.Android 项目上完成了添加 web 参考,它是 apers。
想要实现: Print put "helloworld" into my textview
但是当我写这个的时候。PS:我调用了referens (GetResultFromDB),Connector是 *.cs 文件
TextView textfält = FindViewById<TextView>(Resource.Id.textviewPrintout);
try
{
GetResultFromDB.Connector result = new GetResultFromDB.Connector();
String test = result.HelloWorld();
textfält.Text = test;
}
catch (Exception a) {
textfält.Text = "DATA " + a.Data +
"\n" + "HResult " + a.HResult +
"\nMessage " + a.Message +
"\nSource " + a.Source +
"HelpLink " + a.HelpLink +
"\nInnerException" + a.InnerException;
}
答案是:
取电脑的ip,替换localhost。它起作用了
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句