{"record":{"id":"552857fe67f5a591","repo":"dotnet/wpf","slug":"sr-xpsviewerrightsmanagementexception","errorCode":null,"errorMessage":"SR.XpsViewerRightsManagementException","messagePattern":"SR\\.XpsViewerRightsManagementException","errorType":"exception","errorClass":"XpsViewerException","httpStatus":null,"severity":"critical","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/RightsManagementErrorHandler.cs","lineNumber":140,"sourceCode":"            {\n                // Display the error message box\n                System.Windows.MessageBox.Show(\n                    message,\n                    SR.RightsManagementWarnErrorTitle,\n                    System.Windows.MessageBoxButton.OK,\n                    System.Windows.MessageBoxImage.Warning);\n            }\n\n            // If the exception is fatal and the operation is critical, we\n            // should throw an XPS Viewer exception to be handled higher up\n            // the stack\n            if (fatal && IsCriticalOperation(operation))\n            {\n                Trace.SafeWrite(\n                    Trace.Rights,\n                    \"ErrorHandler: Could not handle exception. Rethrowing.\");\n\n                throw new XpsViewerException(\n                    SR.XpsViewerRightsManagementException,\n                    exception);\n            }\n\n            Trace.SafeWrite(\n                Trace.Rights,\n                \"ErrorHandler: Handled exception.\");\n\n            return !fatal;\n        }\n\n        #endregion Internal Methods\n\n        #region Private Methods\n        //------------------------------------------------------\n        // Private Methods\n        //------------------------------------------------------\n","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/RightsManagementErrorHandler.cs#L122-L158","documentation":"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.","triggerScenarios":"A fatal RightsManagementException occurs during an operation classified as critical (e.g., decrypting a protected XPS document during load).","commonSituations":"Opening a protected XPS without a valid use-license; expired or revoked RM certificate; RM server unreachable during a critical decrypt step.","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"],"exampleFix":"// before\nvar xpsDoc = new XpsDocument(protectedPath, FileAccess.Read);\n// after\ntry { var xpsDoc = new XpsDocument(protectedPath, FileAccess.Read); }\ncatch (XpsViewerException ex)\n{\n    var rmEx = ex.InnerException as RightsManagementException;\n    // report rmEx.StatusCode to the user\n}","handlingStrategy":"try-catch","validationCode":"if (!userLicense.HasEditRights) { /* acquire rights or open read-only before the critical operation */ }","typeGuard":null,"tryCatchPattern":"try { OpenProtectedDocument(path); } catch (XpsViewerException ex) { var rm = ex.InnerException as RightsManagementException; /* report rm.StatusCode */ }","preventionTips":["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"],"tags":["wpf","rights-management","drm","xps"],"backgroundTag":"authentication-required","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}