我正在使用此代码来读取对等数据和评论:
public Dictionary<int, string> ResolvePeerMethod()
{
Dictionary<int, string> peerInfo = new Dictionary<int, string>();
int count = 0;
string[] peerinfo = new string[1];
PeerNameResolver resolver = new PeerNameResolver();
PeerName peerName123 = new PeerName("peer id");
PeerNameRecordCollection results = resolver.Resolve(peerName123);
foreach (PeerNameRecord record in results)
{
if (record.Comment != null)
{
peerinfo[0] = record.Comment;
peerInfo.Add(0, peerinfo[0]);
}
if (record.Data != null)
{
peerinfo[1] = (System.Text.Encoding.ASCII.GetString(record.Data));
peerInfo.Add(1, peerinfo[1]);
}
}
return peerInfo;
}
这应该返回一个包含数据和注释的字典,但它只是跳过代码,因为它在对等点中找不到任何记录。在控制台中运行相同的代码是可行的。peer id
是正确的;我已经检查了好几次了。