dotnet/wpf · critical · XpsViewerException
SR.XpsViewerRightsManagementException
Error message
SR.XpsViewerRightsManagementException
What it means
RightsManagementManager.SetEncryptedPackage decrypts a rights-managed XPS package; when decryption throws, RightsManagementErrorHandler.HandleOrRethrowException runs first, then the code unconditionally rethrows the exception wrapped in XpsViewerException(SR.XpsViewerRightsManagementException). This is the XPS Viewer's generic wrapper for rights-management failures during package decryption.
Solutions
- Inspect the InnerException (the original rights-management exception) to find the root cause; fix that underlying RMS condition.
- Verify RMS service connectivity and that the user can acquire a use license (open the document via a known-good client to test).
- Re-acquire credentials/use license (re-activate the RMS client, sign in with the entitled account).
- Catch XpsViewerException around document open and show a friendly 'cannot open protected document' message with inner details for support.
Example fix
// before
xpsViewer.Open(docPath); // throws XpsViewerException wrapping RMS failure
// after
try { xpsViewer.Open(docPath); }
catch (XpsViewerException ex)
{
ShowRmsError(ex.InnerException); // e.g. license expired / server unreachable
} Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-check: can the current user acquire a use license for this document? // Open a trial SecureEnvironment / query RM enabler before loading the document.
Try / catch
try { manager.SetEncryptedPackage(packageStream); }
catch (XpsViewerException ex)
{ HandleRmFailure(ex.InnerException); // license/server/credential diagnostics } Prevention
- Ensure the user has a valid use license before opening protected XPS.
- Verify RMS server reachability and client activation.
- Surface InnerException details for support.
- Handle expired credentials by re-authenticating the user.
When it happens
Trigger: Opening a protected XPS document where SetEncryptedPackage's Decrypt operation fails — missing/invalid use license, unreachable RMS server, corrupt encrypted package, or expired credentials.
Common situations: User without a valid license opens an RM-protected XPS; RMS server unreachable/offline; client machine lacks RMS initialization; document encrypted with keys the current account cannot obtain.
Related errors
- SR.RightsManagementExceptionNoRightsForOperation
- SR.XpsViewerRightsManagementException
- " }} " element found. Expected fixed page element ( }} ).
- ' ' ContentType is not valid.
- ' ' ContentType is not valid.
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/93ab61934a5d20c1.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementManager.cs:210
internal void SetEncryptedPackage(EncryptedPackageEnvelope newPackage)
{
bool publishLicenseChanged = true;
try
{
_rmProvider.SetEncryptedPackage(
newPackage,
out publishLicenseChanged);
}
catch (RightsManagementException exception)
{
RightsManagementErrorHandler.HandleOrRethrowException(
RightsManagementOperation.Decrypt,
exception);
// On an exception here we can't continue; rethrow it in an
// XPSViewer exception
throw new XpsViewerException(
SR.XpsViewerRightsManagementException,
exception);
}
if (_rmProvider.IsProtected)
{
// Get a use license for the new package
RightsManagementLicense license = GetUseLicense();
if (license == null ||
!license.HasPermission(RightsManagementPermissions.AllowView))
{
throw new XpsViewerException(
SR.RMProviderExceptionNoRightsToDocument);
}
}
if (publishLicenseChanged)View on GitHub (pinned to 81131a70a4)