创建PrintServer对象时发生异常。 Win32错误:打印机名称无效 [英] exception occurred while creating the PrintServer object. Win32 error: The printer name is invalid

查看:1625
本文介绍了创建PrintServer对象时发生异常。 Win32错误:打印机名称无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建printserver对象时遇到此异常。这是我的代码



Hi i am getting this exception when i am trying to create printserver object. Here is my code

PrintServer printServer = new PrintServer(@"\\" + printServerName);
PrintQueue printQueue = printServer.GetPrintQueue(printerName);





我试图从另一台机器上获取打印机,这是Windows服务器2012年,如果我试图访问一些基于操作系统的系统,相同的代码工作正常。任何帮助将不胜感激。在此先感谢



I trying to get the printers from another machine which is windows server 2012, same code works fine if i try to acess some OS based system. Any help will be appreciated. Thanks in advance

推荐答案

我找到了答案,我知道其他许多人也在寻找这个问题。



由于Windows功能/角色打印和文档服务在系统上缺失,因此出现此问题。管理多台打印机或打印服务器以及将打印机与其他Windows服务器进行迁移需要此角色。



添加角色转到控制面板 - >转动窗口功能打开或关闭 - >单击复选框打印和文档服务 - >安装。



如果您无法安装此规则,请与网络管理员联系添加它。



添加角色后,您可以创建打印服务器对象并获取相应服务器上的所有打印队列。
I found the answer for this, and i know many others are also looking for this issue.

This issue was occuring due to windows feature/role "Print and Document service" is missing on the system. This role is required for managing multiple printers or print servers and migrating printers to and from other windows servers.

To add the role Go To Control Panel->Turn windows feature on or off->click on check box "Print and Document Service"->install.

See with network administrator for installing this rule if you unable to add it.

After adding the role you can able to create print server object and get the all the printqueues on respective server.


这篇关于创建PrintServer对象时发生异常。 Win32错误:打印机名称无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆