{"record":{"id":"b44f81245aea92cc","repo":"dotnet/wpf","slug":"printsystemexception-printsystemjobinfo-deleted","errorCode":null,"errorMessage":"PrintSystemException.PrintSystemJobInfo.Deleted","messagePattern":"PrintSystemException\\.PrintSystemJobInfo\\.Deleted","errorType":"exception","errorClass":"PrintJobException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/PrintSystemJobInfo.cpp","lineNumber":421,"sourceCode":"\n    if (!isDeleted)\n    {\n        try\n        {\n            hostingPrintQueue->PrinterThunkHandler->ThunkSetJob(jobIdentifier, JOB_CONTROL_PAUSE);\n\n            get_InternalPropertiesCollection(\"Status\")->GetProperty(\"Status\")->IsInternallyInitialized = true;\n            this->JobStatusSecondary = static_cast<Int32>(jobStatus | PrintJobStatus::Paused);\n        }\n        catch (InternalPrintSystemException^ internalException)\n        {\n            throw CreatePrintJobException(internalException->HResult,\n                                          \"PrintSystemException.PrintSystemJobInfo.Generic\");\n        }\n    }\n    else\n    {\n       throw CreatePrintJobException(\"PrintSystemException.PrintSystemJobInfo.Deleted\");\n    }\n}\n\n\nvoid\nPrintSystemJobInfo::\nResume(\n    void\n    )\n{\n    VerifyAccess();\n\n    if (!isDeleted)\n    {\n        try\n        {\n            hostingPrintQueue->PrinterThunkHandler->ThunkSetJob(jobIdentifier, JOB_CONTROL_RESUME);\n","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/PrintSystemJobInfo.cpp#L403-L439","documentation":"PrintSystemJobInfo.Pause was called on a job that is already in the Deleted state (JobStatus & Deleted != 0). Instead of attempting a spooler call, the method throws PrintSystemException with key 'PrintSystemException.PrintSystemJobInfo.Deleted'. You cannot pause a job that no longer exists in the print queue.","triggerScenarios":"Calling Pause() on a PrintSystemJobInfo object cached from earlier while the job has since been deleted — e.g. it finished printing, was cancelled via Cancel(), or the user removed it from the print queue UI.","commonSituations":"Holding stale PrintSystemJobInfo references in a long-running app while jobs complete in the background; multiple components acting on the same job; monitoring code reacting to old queue snapshots.","solutions":["Check (job.JobStatus & PrintJobStatus.Deleted) != 0 before calling Pause","Discard stale PrintSystemJobInfo references and re-fetch job state from the PrintQueue","Treat this as an expected outcome in cleanup/monitoring code — catch and skip","Use PrintQueue.GetPrintJobInfoFilter or refresh queue jobs rather than operating on cached objects"],"exampleFix":"// before\njob.Pause(); // stale reference: job already deleted\n// after\nif ((job.JobStatus & PrintJobStatus.Deleted) == 0)\n{\n    job.Pause();\n}\nelse\n{\n    job = queue.GetJob(job.JobIdentifier); // refresh from spooler\n}","handlingStrategy":"validation","validationCode":"if ((job.JobStatus & PrintJobStatus.Deleted) != 0)\n{\n    // job gone: re-fetch or skip\n    job = job.HostingPrintQueue.GetJob(job.JobIdentifier);\n    if (job == null) return; // genuinely gone\n}\njob.Pause();","typeGuard":"bool IsAlive(PrintSystemJobInfo job) => job != null && (job.JobStatus & PrintJobStatus.Deleted) == 0;","tryCatchPattern":"try { job.Pause(); }\ncatch (PrintSystemException ex) when (ex.Message.Contains(\"PrintSystemJobInfo.Deleted\")) { /* benign: job already gone, refresh or skip */ }","preventionTips":["Never cache PrintSystemJobInfo across long waits; refresh from PrintQueue","Check the Deleted bit before every job mutation","Make job-control workflows idempotent so a deleted job is a no-op","Avoid multiple components issuing commands to the same job concurrently"],"tags":["wpf","printing","stale-state","job-deleted"],"backgroundTag":"invalid-state-transition","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"}