{"record":{"id":"5d7ecd2d5b9b4b2b","repo":"dotnet/wpf","slug":"sr-rmexceptiongenericmessage","errorCode":null,"errorMessage":"SR.RmExceptionGenericMessage","messagePattern":"SR\\.RmExceptionGenericMessage","errorType":"exception","errorClass":"MS.Internal.Security.RightsManagement.RightsManagementException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Security/RightsManagement/Errors.cs","lineNumber":61,"sourceCode":"\n            string errorMessage = GetLocalizedFailureCodeMessage((RightsManagementFailureCode)hr);\n            if (errorMessage != null)\n            {\n                throw new RightsManagementException((RightsManagementFailureCode)hr, errorMessage);\n            }\n            else\n            {\n                try\n                {\n                    // It seems that ThrowExceptionForHR is the most consistent way\n                    // to get a platform representation of the unmanaged HR code\n                    Marshal.ThrowExceptionForHR(hr);\n                }\n                // We are re-throwing the same exception wrapped in a more specific message\n                catch (Exception e)\n                {\n                    // rethrow the exception as an inner exception of the RmExceptionGenericMessage\n                    throw new RightsManagementException(SR.RmExceptionGenericMessage, e);\n                }\n            }\n        }\n\n        private static string GetLocalizedFailureCodeMessage(RightsManagementFailureCode failureCode)\n        {\n            string result;\n            switch (failureCode)\n            {\n                case RightsManagementFailureCode.InvalidLicense:\n                    result=nameof(SR.RmExceptionInvalidLicense); break;\n                case RightsManagementFailureCode.InfoNotInLicense:\n                    result=nameof(SR.RmExceptionInfoNotInLicense); break;\n                case RightsManagementFailureCode.InvalidLicenseSignature:\n                    result=nameof(SR.RmExceptionInvalidLicenseSignature); break;\n                case RightsManagementFailureCode.EncryptionNotPermitted:\n                    result=nameof(SR.RmExceptionEncryptionNotPermitted); break;\n                case RightsManagementFailureCode.RightNotGranted:","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Security/RightsManagement/Errors.cs#L43-L79","documentation":"Fallback path in Errors.ThrowOnErrorCode: when the HRESULT has no localized RM failure-code message, the library lets Marshal.ThrowExceptionForHR throw, and if that produces an exception it wraps it in RightsManagementException with the generic SR.RmExceptionGenericMessage and the original exception as InnerException.","triggerScenarios":"Native DRM API returned an HRESULT unknown to the failure-code table (e.g. low-level COM/Win32 errors from the secure environment, corrupted DRM stack state, E_HANDLE/E_OUTOFMEMORY from the client session).","commonSituations":"Broken or outdated RMS client installation; memory/handle exhaustion during long sessions; OS-level security components failing; unexpected native states not covered by the localized message table.","solutions":["Inspect the InnerException of the RightsManagementException — it holds the real HR/cause.","Repair/reinstall the AD RMS client (MSIPC) and confirm DRM DLLs are intact.","Retry the operation; transient native failures (resources, handles) often clear on a fresh session.","Log the original HRESULT from the inner exception and search it against DRM failure-code docs."],"exampleFix":"// before: only message is 'generic RM exception'\ncatch (RightsManagementException ex) { Log(ex.Message); }\n\n// after\ncatch (RightsManagementException ex)\n{\n    Log($\"{ex.Message} caused by {ex.InnerException?.HResult:x8}: {ex.InnerException?.Message}\");\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (RightsManagementException ex) when (ex.InnerException != null)\n{\n    int hr = ex.InnerException.HResult;\n    Log($\"Unmapped DRM HRESULT 0x{hr:X8}: {ex.InnerException.Message}\");\n}","preventionTips":["Always inspect InnerException for the true cause of generic RM exceptions.","Keep the AD RMS client (MSIPC) repaired and up to date.","Dispose ClientSession/SecureEnvironment objects promptly to avoid handle exhaustion."],"tags":["rights-management","drm","generic-exception","native-interop"],"backgroundTag":"wrapped-native-exception","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}