1

I am logged to my computer with domain1\user1 I'm logging on another computer with Remote Desktop using domain2\user1 and try to commit attributes. printQueue.Commit(); throws an error.

Does anyone have any idea why?

    static void Main(string[] args)
    {
        var printerName = "Printer (redirected 2)";

        var printQueue = GetPrinter(printerName);
        if (printQueue == null)
        {
            throw new KeyNotFoundException("Printer " + printerName + " not found.");
        }

        var deltaTicket = new PrintTicket();
        deltaTicket.Duplexing = Duplexing.OneSided;
        deltaTicket.OutputColor = OutputColor.Grayscale;

        var validationResult = printQueue.MergeAndValidatePrintTicket(printQueue.UserPrintTicket, deltaTicket);

        if (validationResult.ValidatedPrintTicket.Duplexing == Duplexing.OneSided)
        {
            printQueue.UserPrintTicket = validationResult.ValidatedPrintTicket;

            printQueue.Commit(); // this line throws an exception
        }
    }


    private static PrintQueue GetPrinter(string printerName)
    {
        var server = new LocalPrintServer();
        var printers = server.GetPrintQueues();
        return printers.FirstOrDefault(printer => printer.Name == printerName);
    }


An unhandled exception of type 'System.Printing.PrintCommitAttributesException'
occurred in PrinterConsoleTest.exe

Additional information: 
An exception occurred while committing the properties for the PrintQueue object. 
Win32 error: The request is not supported.
lixonn
  • 1,033
  • 1
  • 12
  • 28
  • It is an "it did not work" exception. Printing in Windows is notorious for not generating good error codes. You can see a bit more by turning on the Thrown checkboxes in Debug > Exceptions, unlikely to help however. If you don't see a decent event logged in the Windows event log then you'll need help from IT staff. – Hans Passant May 04 '15 at 15:19
  • Nothing in event viewer. The exception I presented above is all we have :( – lixonn May 06 '15 at 09:07

0 Answers0