The following code works without issue from inside Visual Studio (professional or express editions) but when this console app is run from the command line it returns: Win32 Error: The RPC Server is unavailable.
The variations on PrintServer and LocalPrintServer produce the same results. It's also disappointing that sample code provided at
http://msdn.microsoft.com/en-us/library/aa970845(v=VS.100).aspx doesn't work (which is the base of this code)
Prior to installing .net 3.5 framework sdk, I had the same errors as found in this article:
http://connect.microsoft.com/VisualStudio/feedback/details/552520/methodaccessexception-when-printqueuecollection-disposed# with PrintServer (as opposed to LocalPrintServer) but the work around of using .net 3.5 didn't solve the problem, just made
all the errors of the RPC flavour. All the obvious things, like ensuring the RPC server is up and running automatically, firewalls turned off (instead of just adding the application - that fails too), and so on don't help any.