{"record":{"id":"ae8148896d87ed91","repo":"dotnet/wpf","slug":"printsystemexception-printsystemjobinfo-create-ae8148","errorCode":null,"errorMessage":"PrintSystemException.PrintSystemJobInfo.Create","messagePattern":"PrintSystemException\\.PrintSystemJobInfo\\.Create","errorType":"exception","errorClass":"PrintJobException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/PrintSystemJobInfo.cpp","lineNumber":77,"sourceCode":"#include <GetDataThunkObject.hpp>\n#endif\n\n#ifndef  __ENUMDATATHUNKOBJECT_HPP__\n#include <EnumDataThunkObject.hpp>\n#endif\n\nPrintSystemJobInfo::\nPrintSystemJobInfo(\n    PrintQueue^     printQueue,\n    PrintTicket^    printTicket\n    ) : hostingPrintQueue(printQueue),\n        jobName(defaultJobName),\n        printStream(nullptr),\n        accessVerifier(nullptr)\n{\n    if (!hostingPrintQueue)\n    {\n        throw CreatePrintJobException(\"PrintSystemException.PrintSystemJobInfo.Create\",\n                                       gcnew ArgumentNullException(\"printQueue\"));\n    }\n    try\n    {\n        //\n        // Initilizing the Document instance\n        //\n        Initialize();\n\n        printStream = gcnew PrintQueueStream(hostingPrintQueue, jobName, false, printTicket);\n\n        JobIdentifier = printStream->JobIdentifier;\n\n        PopulateJobProperties(refreshPropertiesFilter);\n\n    }\n    catch (SystemException^ internalException)\n    {","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/PrintSystemJobInfo.cpp#L59-L95","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass a valid, non-null PrintQueue instance obtained from a PrintServer (e.g. localServer.GetPrintQueue(\"QueueName\")).","Check the queue lookup result for null before constructing the job; if null, create the queue or surface a friendly error.","If using AddJob/queue.AddJob flows instead, construct the job through the PrintQueue API so the queue is always supplied."],"exampleFix":"// before\nPrintSystemJobInfo job = new PrintSystemJobInfo(null, defaultJobName); // throws\n// after\nPrintQueue queue = printServer.GetPrintQueue(\"MyPrinter\");\nif (queue == null) throw new InvalidOperationException(\"Queue not found\");\nPrintSystemJobInfo job = new PrintSystemJobInfo(queue, defaultJobName);","handlingStrategy":"validation","validationCode":"if (queue is null)\n    throw new ArgumentNullException(nameof(queue), \"A valid PrintQueue is required to create a PrintSystemJobInfo.\");","typeGuard":"static bool CanCreateJob(PrintQueue queue) => queue is not null && !string.IsNullOrEmpty(queue.Name);","tryCatchPattern":"try { var job = new PrintSystemJobInfo(queue, jobName); }\ncatch (PrintSystemException ex) when (ex.InnerException is ArgumentNullException) {\n    Console.WriteLine(\"printQueue was null — supply a valid PrintQueue.\");\n}","preventionTips":["Always null-check the result of GetPrintQueue / queue lookups before constructing jobs.","Enable nullable reference types so a null PrintQueue cannot flow into the constructor unnoticed.","Prefer high-level APIs (PrintQueue.AddJob) that construct jobs with their owning queue.","Don't reorder constructor arguments when refactoring; rely on named intent or wrapper factory methods."],"tags":["printing","wpf","null-argument","printqueue","constructor"],"backgroundTag":"null-argument","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}