{"record":{"id":"7630d540778e212c","repo":"dotnet/wpf","slug":"printsystemexception-printqueue-pause","errorCode":null,"errorMessage":"PrintSystemException.PrintQueue.Pause","messagePattern":"PrintSystemException\\.PrintQueue\\.Pause","errorType":"exception","errorClass":"PrintQueueException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/PrintQueue.cpp","lineNumber":1281,"sourceCode":"\n    Return Value\n        None\n--*/\nvoid\nPrintQueue::\nPause(\n    void\n    )\n{\n    VerifyAccess();\n\n    try\n    {\n        printerThunkHandler->ThunkSetPrinter(PRINTER_CONTROL_PAUSE);\n    }\n    catch (InternalPrintSystemException^ internalException)\n    {\n        throw CreatePrintQueueException(internalException->HResult,\n                                        \"PrintSystemException.PrintQueue.Pause\");\n    }\n}\n\n\n/*++\n    Function Name:\n        Purge\n\n    Description:\n        Deletes all the jobs in the printer\n\n    Parameters:\n        None\n\n    Return Value\n        None\n--*/","sourceCodeStart":1263,"sourceCodeEnd":1299,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/PrintQueue.cpp#L1263-L1299","documentation":"PrintQueue.Pause converts a Win32 SetPrinter(PRINTER_CONTROL_PAUSE) failure into a PrintSystemException tagged 'PrintSystemException.PrintQueue.Pause'. Pausing asks the spooler to stop scheduling jobs on the queue; the HResult holds the native error (e.g. access denied).","triggerScenarios":"Calling queue.Pause() when the spooler rejects SetPrinter with PRINTER_CONTROL_PAUSE — typically ERROR_ACCESS_DENIED, ERROR_INVALID_PRINTER_NAME, or a disconnected remote queue.","commonSituations":"User is not a printer administrator/owner; pausing a connection to a shared printer where the server refuses non-admin control; queue already deleted; spooler service stopped.","solutions":["Run under an account with Manage Printer permission on the queue (printer owner or administrator).","Check the queue still exists via PrintServer.GetPrintQueue(name) before pausing.","Verify the spooler service is running and the network path to the print server is reachable.","Inspect the PrintSystemException's Win32 HResult (e.g. 0x80070005 = access denied) to confirm the permission cause."],"exampleFix":"// before\nqueue.Pause();\n// after\ntry { queue.Pause(); }\ncatch (PrintSystemException ex)\n{\n    if (ex.HResult == unchecked((int)0x80070005)) throw new UnauthorizedAccessException(\"Manage-printer permission required to pause the queue.\", ex);\n    throw;\n}","handlingStrategy":"try-catch","validationCode":"var server = new PrintServer();\nbool exists = server.GetPrintQueues().Any(q => q.FullName == queue.FullName);\nif (!exists || (queue.QueueStatus & PrintQueueStatus.Error) != 0) throw new InvalidOperationException(\"Queue unavailable for Pause\");","typeGuard":null,"tryCatchPattern":"try { queue.Pause(); }\ncatch (PrintSystemException ex) when (ex.HResult == unchecked((int)0x80070005))\n{ throw new UnauthorizedAccessException(\"Manage-printer permission required to pause the queue.\", ex); }","preventionTips":["Require Manage Printer permission for any queue-control operation (Pause/Purge/Resume).","Check QueueStatus before issuing control commands.","Inspect the PrintSystemException HResult to classify Win32 errors.","Operate on queues re-resolved from the PrintServer, not stale references."],"tags":["printing","wpf","permissions"],"backgroundTag":"permission-denied","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"}