C# 枚举IPP打印机
我正在研究Windows 10中基于DNS的服务发现,并从构建中发现。我对discovery所做的唯一更改是将服务名称更改为\u ipp.\u tcp。然而,我没有得到任何点击,即使我知道我在网络上有超过15台支持IPP的打印机,我可以使用IPP工具、IOS和Android代码成功识别这些打印机 我检查了又检查了打字错误。我已经在appxmanifest文件中包含了所有网络功能 这是我的代码,非常简单:C# 枚举IPP打印机,c#,win-universal-app,windows-10,mdns,dns-sd,C#,Win Universal App,Windows 10,Mdns,Dns Sd,我正在研究Windows 10中基于DNS的服务发现,并从构建中发现。我对discovery所做的唯一更改是将服务名称更改为\u ipp.\u tcp。然而,我没有得到任何点击,即使我知道我在网络上有超过15台支持IPP的打印机,我可以使用IPP工具、IOS和Android代码成功识别这些打印机 我检查了又检查了打字错误。我已经在appxmanifest文件中包含了所有网络功能 这是我的代码,非常简单: public sealed partial class MainPage : Page {
public sealed partial class MainPage : Page
{
static Guid DnsSdProtocol = new Guid("{4526e8c1-8aac-4153-9b16-55e86ada0e54}");
string queryString = "System.Devices.AepService.ProtocolId:={" + DnsSdProtocol + "} AND " +
"System.Devices.Dnssd.Domain:=\"local\" AND System.Devices.Dnssd.ServiceName:=\"_ipp._tcp\"";
DeviceWatcher watcher;
public MainPage()
{
this.InitializeComponent();
}
private void button_Click(object sender, RoutedEventArgs e)
{
watcher = DeviceInformation.CreateWatcher(queryString,
new String[]
{
"System.Devices.Dnssd.HostName",
"System.Devices.Dnssd.ServiceName",
"System.Devices.Dnssd.TextAttributes",
"System.Devices.IpAddress" },
DeviceInformationKind.AssociationEndpointService
);
watcher.Added += Watcher_Added;
watcher.Start();
}
private void Watcher_Added(DeviceWatcher sender, DeviceInformation args)
{
System.Diagnostics.Debug.WriteLine("found device");
}
}
是否有其他人对此有经验,并能帮助找出为什么找不到设备?我的问题对吗?设置DeviceWatcher时是否需要执行其他操作
更新
我已经验证了请求正在创建,因为它们显示在Wireshark中。它们看起来与正在创建的其他MDN请求相同。我还验证了我可以创建返回已发现设备的SSDP请求,因此我怀疑这是通过应用程序功能的网络权限问题。尝试使用watcher.Update处理程序。即使它是空的,更新处理程序的存在也会导致触发添加的处理程序