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
- Inspect InnerException for the underlying RightsManagementException and its status code
- Acquire a valid use license (PublishLicense/UseLicense flow) before opening the protected document
- Ensure the RM service / AD Rights Management endpoint is reachable and credentials are valid
- 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
- Acquire and cache a valid use license before opening protected documents
- Verify RM server connectivity and certificate validity up front
- Classify operations so critical decrypt steps run only with rights confirmed
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
- InvalidLicense
- InvalidLicense
- NeedsGroupIdentityActivation
- SR.RightsManagementExceptionNoRightsForOperation
- SR.RightsManagementExceptionNoRightsForOperation
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)