我使用这段代码:
string Address = "192.168.0.1";
DnsEndPoint hostEntry = new DnsEndPoint(Address, 80);
DeviceNetworkInformation.ResolveHostNameAsync(hostEntry, new NameResolutionCallback(nrr =>
{
if (Address == nrr.HostName)
{
HostName = "unknown host";
}
else
{
HostName = nrr.HostName;
}
}), null);
并且 HostName 始终是“未知主机”。请告诉我,我的错误在哪里。