Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What causes System.Drawing.Printing.PrinterSettings.InstalledPrinters to throw Win32Exception "RPC server not available"?

Tags:

c#

.net

printing

I have an application that I'm working on and I allow the user to select a printer to use as their printer while printing forms from the application. I'm using .NET 2.0

In the settings screen, I call

System.Drawing.Printing.PrinterSettings.InstalledPrinters 

to get the list of available printers.

On a client's machine, the property throws an exception:

System.ComponentModel.Win32Exception: The RPC server is unavailable

The client is reporting that windows shows his printer as 'ready', and the client can print test pages from the printer. But, I have not been able to reproduce this issue locally and I'm running out of ideas. Does anyone have any ideas what could cause this issue? Any ideas or directions to look would be helpful. Thanks

like image 733
Richard R Avatar asked Apr 09 '09 15:04

Richard R


2 Answers

This same thing is happening to me in Windows 7. Stopping and starting the print spooler in services fixes until it happens again.

The following commands make it quick to do this:

net stop "print spooler"
net start "print spooler"

Note: Run the command prompt as Admin. I made a batch file to do this because it happens 4-5 times a day during development.

like image 191
Tim Santeford Avatar answered Oct 11 '22 04:10

Tim Santeford


If you can print, most likely a security issue. Otherwise I would have voted "dead spooler service" but more likely your app doesn't have the rights to communicate with the spooler service...

like image 25
KristoferA Avatar answered Oct 11 '22 03:10

KristoferA