dotnet/wpf · error · PrintJobException

PrintSystemException.PrintSystemJobInfo.Create

Error message

PrintSystemException.PrintSystemJobInfo.Create

What it means

Thrown from the PrintSystemJobInfo constructor when it is created with a null hostingPrintQueue. The constructor validates its required argument before initializing the job, and throws a PrintSystemException (lookup key PrintSystemException.PrintSystemJobInfo.Create) wrapping an ArgumentNullException with parameter name "printQueue". It indicates a programming error in the caller, not a printing runtime failure.

Solutions

  1. Pass a valid, non-null PrintQueue instance obtained from a PrintServer (e.g. localServer.GetPrintQueue("QueueName")).
  2. Check the queue lookup result for null before constructing the job; if null, create the queue or surface a friendly error.
  3. If using AddJob/queue.AddJob flows instead, construct the job through the PrintQueue API so the queue is always supplied.

Example fix

// before
PrintSystemJobInfo job = new PrintSystemJobInfo(null, defaultJobName); // throws
// after
PrintQueue queue = printServer.GetPrintQueue("MyPrinter");
if (queue == null) throw new InvalidOperationException("Queue not found");
PrintSystemJobInfo job = new PrintSystemJobInfo(queue, defaultJobName);
Defensive patterns

Strategy: validation

Validate before calling

if (queue is null)
    throw new ArgumentNullException(nameof(queue), "A valid PrintQueue is required to create a PrintSystemJobInfo.");

Type guard

static bool CanCreateJob(PrintQueue queue) => queue is not null && !string.IsNullOrEmpty(queue.Name);

Try / catch

try { var job = new PrintSystemJobInfo(queue, jobName); }
catch (PrintSystemException ex) when (ex.InnerException is ArgumentNullException) {
    Console.WriteLine("printQueue was null — supply a valid PrintQueue.");
}

Prevention

When it happens

Trigger: Calling new PrintSystemJobInfo(null, ...) or passing an uninitialized PrintQueue variable to the PrintSystemJobInfo constructor; deserializing/constructing job objects in factory code where the queue lookup returned null.

Common situations: A queue lookup helper (e.g. from LocalPrintServer.GetPrintQueue) returned null and the result was passed on without checking; refactoring changed constructor argument order so null landed on the printQueue parameter.

Related errors


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/PrintSystemJobInfo.cpp:77

#include <GetDataThunkObject.hpp>
#endif

#ifndef  __ENUMDATATHUNKOBJECT_HPP__
#include <EnumDataThunkObject.hpp>
#endif

PrintSystemJobInfo::
PrintSystemJobInfo(
    PrintQueue^     printQueue,
    PrintTicket^    printTicket
    ) : hostingPrintQueue(printQueue),
        jobName(defaultJobName),
        printStream(nullptr),
        accessVerifier(nullptr)
{
    if (!hostingPrintQueue)
    {
        throw CreatePrintJobException("PrintSystemException.PrintSystemJobInfo.Create",
                                       gcnew ArgumentNullException("printQueue"));
    }
    try
    {
        //
        // Initilizing the Document instance
        //
        Initialize();

        printStream = gcnew PrintQueueStream(hostingPrintQueue, jobName, false, printTicket);

        JobIdentifier = printStream->JobIdentifier;

        PopulateJobProperties(refreshPropertiesFilter);

    }
    catch (SystemException^ internalException)
    {

View on GitHub (pinned to 81131a70a4)