简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM