dotnet/wpf · error · PrintJobException

PrintSystemException.PrintSystemJobInfo.Create

Error message

PrintSystemException.PrintSystemJobInfo.Create

What it means

Thrown when a PrintQueueStream (job creation path in PremiumPrintStream) fails to start a print job. ThunkStartDocPrinter or ThunkOpenSpoolStream fails and the InternalPrintSystemException is converted via PrintSystemJobInfo.CreatePrintJobException with the Create key — the spooler refused to create/open the job's spool stream.

Solutions

  1. Check queue state before streaming: queue.IsOffline, queue.IsPaused, queue.IsNotAvailable, queue.HasPaperProblem.
  2. Verify the Print Spooler service and spool directory disk space on both client and server.
  3. Ensure the user has print permission on the queue and, for remote queues, that the queue is connected.
  4. Confirm the driver supports the job type (XPS/Enhanced Metafile); reinstall/update the driver if StartDocPrinter fails consistently.

Example fix

// before
using (var stream = new PrintQueueStream(queue, "MyJob")) { /* write */ }
// after
if (queue.IsOffline || queue.IsPaused || queue.IsNotAvailable)
    throw new InvalidOperationException("Queue not accepting jobs: " + queue.FullName);
using (var stream = new PrintQueueStream(queue, "MyJob")) { /* write */ }
Defensive patterns

Strategy: validation

Validate before calling

static void EnsureQueueAcceptsJobs(PrintQueue queue)
{
    queue.Refresh();
    if (queue.IsOffline || queue.IsPaused || queue.IsNotAvailable || queue.HasPaperProblem)
        throw new InvalidOperationException($"Queue {queue.FullName} is not accepting jobs");
}

Type guard

static bool QueueReady(PrintQueue q) => !q.IsOffline && !q.IsPaused && !q.IsNotAvailable;

Try / catch

try
{
    using var stream = new PrintQueueStream(queue, jobName) { };
}
catch (PrintSystemException ex)
{
    logger.LogError(ex.InnerException, "Job creation failed on {Queue}", queue.FullName);
    throw new InvalidOperationException("Printer not accepting jobs", ex);
}

Prevention

When it happens

Trigger: Creating a PrintQueueStream (or calling PrintQueue.CreateXpsDocumentWriter / AddJob paths that start a doc) when the queue is paused/offline/error state, the printer driver rejects the job, the spooler is stopped, or the user lacks print permission on the queue.

Common situations: Printing to a network queue whose server is down; driver mismatch (e.g. XPS-capable driver required); queue out of disk space in the spool directory; jobs submitted from services without a printer connection.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/7534e8048813069e. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/PremiumPrintStream.cpp:186

        // (winspool.h only defines one bit in this field).   Naturally, we have
        // to clear that bit (in all overrides of ThunkStartDocPrinter before
        // passing the DocInfoThree into the OS printing components.
        Int32 flags = fastCopy ? 0x40000001 : 1;        // 0x40000000 = fastCopy

        printerThunkHandler = printQueue->CreatePrintThunkHandler();

        DocInfoThree^ docInfo = gcnew DocInfoThree(printJobName,
                                                   printQueue->QueuePort->Name,
                                                   DocInfoThree::defaultDataType,
                                                   flags);

        jobIdentifier = printerThunkHandler->ThunkStartDocPrinter(docInfo, printTicket);

        printerThunkHandler->ThunkOpenSpoolStream();
    }
    catch (InternalPrintSystemException^ internalException)
    {
        throw PrintSystemJobInfo::CreatePrintJobException(internalException->HResult,
                                      "PrintSystemException.PrintSystemJobInfo.Create");
    }
}

PrintQueueStream::
~PrintQueueStream(
    )
{
    Close();
}

PrintQueueStream::
!PrintQueueStream(
    )
{
    isFinalizer = true;

    //Attempt to close unmanaged resources only

View on GitHub (pinned to 81131a70a4)