【发布时间】:2013-10-25 08:47:49
【问题描述】:
我不知道为什么这不起作用:
PrintServer printServer = new PrintServer("\\\\servername");
我遇到了 PrintServer 初始化问题。即使提供的打印机服务器路径是有效路径,上述异常也会继续出现。之所以这么说,是因为我能够使用printerServer.GetPrintQueues 枚举所有打印机并foreach printQueue 以获取相应的HostingPrintServer 名称。
EnumeratedPrintQueueTypes[] queueTypesArray = new EnumeratedPrintQueueTypes[]
{
EnumeratedPrintQueueTypes.Connections,
EnumeratedPrintQueueTypes.Local,
};
PrintQueueIndexedProperty[] indexPropertyArray = new PrintQueueIndexedProperty[]
{
PrintQueueIndexedProperty.Name
};
PrintServer printServer = new PrintServer();
PrintQueueCollection queueCollection = printServer.GetPrintQueues(indexPropertyArray, queueTypesArray);
foreach (PrintQueue pq in queueCollection)
{
if (pq.FullName == printerName)
{
this.printServerName = pq.HostingPrintServer.Name;
this.printerName = pq.Name;
}
}
我也尝试过使用这篇文章建议的方式来获取 DNS hostEntry,但没有任何运气。
PrintServerException - "...name is invalid" even though I can access the path from windows
供您参考,我正在使用在 Windows XP 上运行的 Visual Studio 2010,并连接了两台网络打印机。打印机可以使用 PrintDocument 毫无问题地执行打印,并且打印机也会显示在 PrintDialog 上。
以前有人遇到过这个问题吗?如果是,请问您是如何解决问题的?
提前致谢。
编辑:
刚刚用另一台“真正的”服务器打印机进行了测试,上述方法工作正常。据信,我不确定它的行为是如何导致问题的 Novell iPrint 服务。如果有人知道更多关于使用 C# 访问 Novell iPrint 打印服务器的方法,请随时分享。我目前仍在寻找 解决方案。
【问题讨论】:
标签: c# winforms novell system.printing