我出了主意,为什么这不工作:printserver引发“Win32错误:打印机名称无效。”尽管异常所提供的服务器路径是正确的
PrintServer printServer = new PrintServer("\\\\servername");
我有打印服务器的初始化问题。即使提供的打印机服务器路径是有效路径,上述异常仍会出现。这是因为我能枚举所有打印机使用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
为了您的信息,我使用Visual Studio 2010,其中连接两个网络打印机在Windows XP上运行。打印机能够使用PrintDocument执行打印而没有任何问题,并且打印机也显示在PrintDialog上。
之前是否有人遇到这个问题?如果是,我可否知道你如何解决这个问题?
百万在此先感谢。
编辑:
只是另一种“真正的”服务器打印机进行测试,上述方法是工作的罚款。据我所知,Novell iPrint服务,我不知道它是如何导致问题的行为。如果有人对使用C#访问Novell iPrint打印服务器的方式有更多了解,请随时分享。我目前仍在寻找 解决方案。