dotnet/wpf · critical · XpsViewerException

SR.XpsViewerRightsManagementException

Error message

SR.XpsViewerRightsManagementException

What it means

RightsManagementErrorHandler.HandleOrRethrowException wraps rights-management (RM) failures. If the exception is fatal and occurred during a critical operation, it cannot be handled, so it rethrows as XpsViewerException(SR.XpsViewerRightsManagementException) with the original exception as InnerException.

Solutions

  1. Inspect InnerException for the underlying RightsManagementException and its status code
  2. Acquire a valid use license (PublishLicense/UseLicense flow) before opening the protected document
  3. Ensure the RM service / AD Rights Management endpoint is reachable and credentials are valid
  4. Catch XpsViewerException around the protected-document open and show an RM-specific error dialog

Example fix

// before
var xpsDoc = new XpsDocument(protectedPath, FileAccess.Read);
// after
try { var xpsDoc = new XpsDocument(protectedPath, FileAccess.Read); }
catch (XpsViewerException ex)
{
    var rmEx = ex.InnerException as RightsManagementException;
    // report rmEx.StatusCode to the user
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!userLicense.HasEditRights) { /* acquire rights or open read-only before the critical operation */ }

Try / catch

try { OpenProtectedDocument(path); } catch (XpsViewerException ex) { var rm = ex.InnerException as RightsManagementException; /* report rm.StatusCode */ }

Prevention

When it happens

Trigger: A fatal RightsManagementException occurs during an operation classified as critical (e.g., decrypting a protected XPS document during load).

Common situations: Opening a protected XPS without a valid use-license; expired or revoked RM certificate; RM server unreachable during a critical decrypt step.

Related errors


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/RightsManagementErrorHandler.cs:140

            {
                // Display the error message box
                System.Windows.MessageBox.Show(
                    message,
                    SR.RightsManagementWarnErrorTitle,
                    System.Windows.MessageBoxButton.OK,
                    System.Windows.MessageBoxImage.Warning);
            }

            // If the exception is fatal and the operation is critical, we
            // should throw an XPS Viewer exception to be handled higher up
            // the stack
            if (fatal && IsCriticalOperation(operation))
            {
                Trace.SafeWrite(
                    Trace.Rights,
                    "ErrorHandler: Could not handle exception. Rethrowing.");

                throw new XpsViewerException(
                    SR.XpsViewerRightsManagementException,
                    exception);
            }

            Trace.SafeWrite(
                Trace.Rights,
                "ErrorHandler: Handled exception.");

            return !fatal;
        }

        #endregion Internal Methods

        #region Private Methods
        //------------------------------------------------------
        // Private Methods
        //------------------------------------------------------

View on GitHub (pinned to 81131a70a4)