dotnet/wpf · error · PrintServerException

PrintSystemException.PrintServer.Generic

Error message

PrintSystemException.PrintServer.Generic

What it means

The parameterless LocalPrintServer constructor initializes the object against the local print spooler and requests all server properties. If the underlying spooler call fails (wrapped as InternalPrintSystemException), it is translated via CreatePrintServerException with the message key 'PrintSystemException.PrintServer.Generic', producing a PrintSystemException whose HResult carries the Win32 spooler error (e.g. service stopped, access denied).

Solutions

  1. Start/restart the Print Spooler service: run 'net start spooler' or check services.msc.
  2. Catch PrintSystemException and inspect its HResult/inner Win32 error to identify the spooler failure (0x800706BA RPC unavailable, 0x5 access denied, etc.).
  3. Ensure the process runs as a user with rights to the local print server; use the PrintSystemDesiredAccess overload to request only needed access.
  4. If running in a service or container, enable/print-enable the spooler or run on a machine with a functioning print subsystem.
  5. Repair spooler state: clear %SYSTEMROOT%\System32\spool\PRINTERS queued jobs and restart the service.

Example fix

// before
var server = new LocalPrintServer(); // throws if spooler is stopped

// after
try
{
    var server = new LocalPrintServer();
}
catch (PrintSystemException ex)
{
    // check spooler service / permissions using ex.HResult
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify the spooler service is running before constructing LocalPrintServer
using var sc = new System.ServiceProcess.ServiceController("Spooler");
bool ready = sc.Status == System.ServiceProcess.ServiceControllerStatus.Running;
if (!ready) throw new InvalidOperationException("Print Spooler service is not running");

Type guard

static bool SpoolerAvailable()
{
    try
    {
        using var sc = new System.ServiceProcess.ServiceController("Spooler");
        return sc.Status == System.ServiceProcess.ServiceControllerStatus.Running;
    }
    catch { return false; }
}

Try / catch

try
{
    using var server = new LocalPrintServer();
}
catch (PrintSystemException ex)
{
    // ex.HResult -> Win32 spooler error (access denied / service unavailable)
    logger.LogError(ex, "LocalPrintServer init failed, HResult=0x{HR:X}", ex.HResult);
}

Prevention

When it happens

Trigger: Executing new LocalPrintServer() when the Print Spooler (Spooler) service is not running, RPC to the spooler fails, or the caller lacks permission to query server properties — Initialize() throws InternalPrintSystemException caught at LocalPrintServer.cpp:100-103.

Common situations: Print Spooler service disabled or crashed on the machine; running in a service/session (e.g. IIS, non-interactive Windows service) without spooler access; missing printer drivers/spooler corruption; restricted user accounts or group policy blocking print server enumeration.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/fc173b220cf8741d. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/LocalPrintServer.cpp:102

LocalPrintServer::
LocalPrintServer(
    void
    ):
PrintServer(),
defaultPrintQueue(nullptr),
accessVerifier(nullptr)
{
    try
    {
        Initialize();

        this->IsInternallyInitialized = true;

        refreshPropertiesFilter = LocalPrintServer::GetAllPropertiesFilter();
    }
    catch (InternalPrintSystemException^ internalException)
    {
        throw CreatePrintServerException(internalException->HResult, "PrintSystemException.PrintServer.Generic");
    }
}

/*++

Routine Name:

    LocalPrintServer

Routine Description:

    Constructor

Arguments:

    type    - print server type.

Return Value:

View on GitHub (pinned to 81131a70a4)