Exception occurred while creating the PrintServer object. Win32 error: The printer name is invalid

寵の児 提交于 2019-12-11 04:36:53

问题


Hi, I'm getting this exception when I try to create printserver object. Here is my code:

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

I'm trying to get the printers from another machine which is running on Windows Server 2012. Same code works fine if I try to access some OS based system. Any help will be appreciated. Thanks in advance.


回答1:


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.



来源:https://stackoverflow.com/questions/22959842/exception-occurred-while-creating-the-printserver-object-win32-error-the-print

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!