dotnet/wpf · error · PrintServerException
PrintSystemException.PrintServer.Refresh
Error message
PrintSystemException.PrintServer.Refresh
What it means
PrintServer.Refresh reloads server properties from the spooler. When GetDataFromServer fails for any refresh property with an InternalPrintSystemException, the HRESULT is re-thrown as PrintSystemException keyed 'PrintSystemException.PrintServer.Refresh'. It means reading current settings from the print server failed.
Solutions
- Verify connectivity to the print server and that its spooler service is running
- Check HResult for access-denied (5) vs RPC unavailable errors
- Re-create the PrintServer object with a valid name and retry Refresh
- Run under credentials with read access to the server
Example fix
// before
server.Refresh(); // throws if server unreachable
// after
try { server.Refresh(); }
catch (PrintSystemException ex)
{
Console.WriteLine($"Refresh failed 0x{ex.HResult:X}; using cached values");
} Defensive patterns
Strategy: try-catch
Validate before calling
try { Dns.GetHostEntry(serverHost); }
catch (SocketException) { throw new InvalidOperationException("Print server unreachable: " + serverHost); } Type guard
static bool CanRefresh(PrintServer s) =>
s != null && ServiceController
.GetServices(s.Name == "" ? "." : s.Name)
.Any(x => x.ServiceName == "Spooler" && x.Status == ServiceControllerStatus.Running); Try / catch
try { server.Refresh(); }
catch (PrintSystemException ex)
{ Log.Warn($"Refresh failed 0x{ex.HResult:X}; using cached data"); } Prevention
- Confirm network/server availability before Refresh
- Keep cached property values as fallback
- Catch and treat refresh failure as degradation, not fatal
- Check spooler health on the remote host
When it happens
Trigger: Calling PrintServer.Refresh when one or more property queries to the spooler (GetDataFromServer) return a failure HRESULT.
Common situations: Remote server offline or renamed; access denied; spooler stopped; network failure between client and print server.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- PrintSystemException.PrintQueue.Populate
- PrintSystemException.PrintServer.Commit
- PrintSystemException.PrintServer.Generic
- PrintSystemException.PrintServer.MajorVersionCannotChange
- PrintSystemException.PrintServer.MinorVersionCannotChange
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/db1a7b7d20e039f5.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/PrintServer.cpp:1131
PrintServer::
Refresh(
void
)
{
VerifyAccess();
try
{
for(int numOfProperties = 0;
numOfProperties < refreshPropertiesFilter->Length;
numOfProperties++)
{
GetDataFromServer(refreshPropertiesFilter[numOfProperties], true);
}
}
catch (InternalPrintSystemException^ internalException)
{
throw CreatePrintServerException(internalException->HResult, "PrintSystemException.PrintServer.Refresh");
}
}
/*++
Routine Name:
InternalDispose
Routine Description:
Internal Dispose method.
Arguments:
None
Return Value:View on GitHub (pinned to 81131a70a4)