cta*_*cke 12 c# xamarin.android
我正在尝试使用Mono for Android获取我的Android设备的本地IP地址,但是失败了.
我用于完整和紧凑框架的代码是这样的:
var iplist = (from a in Dns.GetHostAddresses(Dns.GetHostName())
where a.AddressFamily == AddressFamily.InterNetwork
select a).ToArray();
LocalAddress = iplist[0];
Run Code Online (Sandbox Code Playgroud)
但是,在M4A下,它会提前崩溃 - Dns.GetHostName()调用失败
System.Net.Sockets.SocketException: An address incompatible with the requested protocol was used
M4A下的Dns.GetHostName是否存在已知问题?有没有其他方法可以使用M4A获取本地地址?
| 归档时间: |
|
| 查看次数: |
1480 次 |
| 最近记录: |