0

I'm attempting to create a PrintServer using the following code

    PrintServer printServer = new PrintServer(@"\\PrinterName");
    PrintQueueCollection printQueues = printServer.GetPrintQueues();

    foreach(PrintQueue pq in printQueues)
    {
        Console.WriteLine(pq.Name);
    }

but it seems that whatever I put in throws the following exception:

System.Printing.PrintServerException: 'An exception occurred while creating the PrintServer object. Win32 error: The printer name is invalid.'

It may be that I'm putting in the wrong printer name every time, but having tried every possible combination of path I can think of for a few different printers and having the same issue each time I've run out of things to try for this.

I tried following the enabling the Print and Document service as per the advice shown in this question but it hasn't yet helped.

OliverRadini
  • 6,238
  • 1
  • 21
  • 46
  • You do have permissions on that PrinterName server? Are you testing this from a console app? – rene Mar 22 '19 at 16:53
  • @rene yes, I am testing it from a console app. I'm not sure if I have permissions, I can print from that printer but I'm not too clear beyond that – OliverRadini Mar 22 '19 at 18:38

0 Answers0