{"record":{"id":"7534e8048813069e","repo":"dotnet/wpf","slug":"printsystemexception-printsystemjobinfo-create","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/PremiumPrintStream.cpp","lineNumber":186,"sourceCode":"        // (winspool.h only defines one bit in this field).   Naturally, we have\n        // to clear that bit (in all overrides of ThunkStartDocPrinter before\n        // passing the DocInfoThree into the OS printing components.\n        Int32 flags = fastCopy ? 0x40000001 : 1;        // 0x40000000 = fastCopy\n\n        printerThunkHandler = printQueue->CreatePrintThunkHandler();\n\n        DocInfoThree^ docInfo = gcnew DocInfoThree(printJobName,\n                                                   printQueue->QueuePort->Name,\n                                                   DocInfoThree::defaultDataType,\n                                                   flags);\n\n        jobIdentifier = printerThunkHandler->ThunkStartDocPrinter(docInfo, printTicket);\n\n        printerThunkHandler->ThunkOpenSpoolStream();\n    }\n    catch (InternalPrintSystemException^ internalException)\n    {\n        throw PrintSystemJobInfo::CreatePrintJobException(internalException->HResult,\n                                      \"PrintSystemException.PrintSystemJobInfo.Create\");\n    }\n}\n\nPrintQueueStream::\n~PrintQueueStream(\n    )\n{\n    Close();\n}\n\nPrintQueueStream::\n!PrintQueueStream(\n    )\n{\n    isFinalizer = true;\n\n    //Attempt to close unmanaged resources only","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/PremiumPrintStream.cpp#L168-L204","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check queue state before streaming: queue.IsOffline, queue.IsPaused, queue.IsNotAvailable, queue.HasPaperProblem.","Verify the Print Spooler service and spool directory disk space on both client and server.","Ensure the user has print permission on the queue and, for remote queues, that the queue is connected.","Confirm the driver supports the job type (XPS/Enhanced Metafile); reinstall/update the driver if StartDocPrinter fails consistently."],"exampleFix":"// before\nusing (var stream = new PrintQueueStream(queue, \"MyJob\")) { /* write */ }\n// after\nif (queue.IsOffline || queue.IsPaused || queue.IsNotAvailable)\n    throw new InvalidOperationException(\"Queue not accepting jobs: \" + queue.FullName);\nusing (var stream = new PrintQueueStream(queue, \"MyJob\")) { /* write */ }","handlingStrategy":"validation","validationCode":"static void EnsureQueueAcceptsJobs(PrintQueue queue)\n{\n    queue.Refresh();\n    if (queue.IsOffline || queue.IsPaused || queue.IsNotAvailable || queue.HasPaperProblem)\n        throw new InvalidOperationException($\"Queue {queue.FullName} is not accepting jobs\");\n}","typeGuard":"static bool QueueReady(PrintQueue q) => !q.IsOffline && !q.IsPaused && !q.IsNotAvailable;","tryCatchPattern":"try\n{\n    using var stream = new PrintQueueStream(queue, jobName) { };\n}\ncatch (PrintSystemException ex)\n{\n    logger.LogError(ex.InnerException, \"Job creation failed on {Queue}\", queue.FullName);\n    throw new InvalidOperationException(\"Printer not accepting jobs\", ex);\n}","preventionTips":["Refresh and check queue state flags before submitting jobs","Ensure the spool directory has free disk space","Verify the driver supports the job type and the user has print permission","Connect to remote queues before streaming jobs to them"],"tags":["printing","print-job","spooler","wpf"],"backgroundTag":"api-error-response","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}