简体   繁体   English

创建PrintServer对象时发生异常。 Win32错误:打印机名称无效

[英]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. 嗨,当我尝试创建printserver对象时遇到了这个异常。 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. 我正在尝试从运行Windows Server 2012的另一台计算机上获取打印机。如果尝试访问某些基于OS的系统,则相同的代码可以正常工作。 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. 由于Windows功能/角色“系统没有打印和文档服务”,因此出现了此问题。 This role is required for managing multiple printers or print servers and migrating printers to and from other windows servers. 管理多个打印机或打印服务器以及将打印机迁移到其他Windows服务器或从其他Windows服务器迁移时,需要此角色。

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. 添加角色后,您可以创建打印服务器对象并获取相应服务器上的所有打印队列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 System.Printing.PrintServerException:创建PrintServer对象时发生异常。 Win32错误:Windows服务拒绝访问 - System.Printing.PrintServerException: An exception occurred while creating the PrintServer object. Win32 error: Access is denied as a windows service 新 PrintServer object 失败,“打印机名称无效” - New PrintServer object fails, "printer name is invalid" PrintTicket提供程序无法绑定到打印机。 Win32错误:打印机名称无效 - PrintTicket provider failed to bind to printer. Win32 error: The printer name is invalid w3wp.exe 中出现未处理的 win32 异常 - an unhandled win32 exception occurred in w3wp.exe Win32异常 - Win32 Exception 发生错误时如何关闭 Win32 SaveFileDialog? - How to close Win32 SaveFileDialog when an error has occurred? 如何找到Win32异常“错误创建窗口句柄”的源 - How to find source for win32 exception “error creating window handle” (WIN32:1400 ERROR_INVALID_WINDOW_HANDLE)使用智能卡签名CSR时 - (WIN32: 1400 ERROR_INVALID_WINDOW_HANDLE) while Signing a CSR with a SmartCard Win32Exception:目录名无效 - Win32Exception: The directory name is invalid Win32 异常:尝试使用 OpenProcess 时拒绝访问 - Win32 Exception: Access is denied while attempting to use OpenProcess
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM