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

13,540

Solution 1

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...

Solution 2

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.

Solution 3

Either the RPC service is off or Windows Firewall is blocking it.

Solution 4

I had a similar problem using PrinterSettings.InstalledPrinters and the cause was that the application was running with "Partial Trust" permissions.

In Visual Studio, went to Project Properties\Security and selected "This is a full trust application".

I'm not sure if this is going to help you but did it for me.

Solution 5

Another possibility is also that the PrintSpooler service has been set to Disabled

Share:
13,540
Richard R
Author by

Richard R

A guy who likes building stuff.

Updated on July 25, 2022

Comments

  • Richard R
    Richard R almost 2 years

    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

  • Richard R
    Richard R about 15 years
    The printers on the client machine are connected via USB.
  • Richard R
    Richard R over 14 years
    Yea, it was a dead spooler service. Installing the printer drivers was causing the printer to spooler service to die. I ended up pushing this issue onto the Printer Manufacturer after I isolated this exception to a specific installation of the printer as opposed to all of them.
  • neoscribe
    neoscribe almost 10 years
    Wow. In my case, I had an ASP.Net web app that was using Crystal Reports to generate a PDF. Turns out it was throwing the "(0x80004005): The RPC server is unavailable" exception during the process of generating the PDF. I'm not sure why it needs the spooler to be running, but your solution fixed my problem!
  • John Dyer
    John Dyer over 2 years
    This is what I found for me. I'm thinking our IT dept disables the print spooler on servers. I set the service to manual, started it up and then the error went away. Interesting is that Windows 10 setup / devices / printers clearly shows printers with no hint that the print spooler service isn't running. I did finally get an error about the spooler when I tried to "install a printer" when printing a test page from notepad.