{"record":{"id":"736ec71dbfc7cdb7","repo":"dotnet/wpf","slug":"document-contains-multiple-rights-management-encryption","errorCode":null,"errorMessage":"Document contains multiple Rights Management Encryption Transforms.","messagePattern":"Document contains multiple Rights Management Encryption Transforms\\.","errorType":"exception","errorClass":"FileFormatException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/EncryptedPackage.cs","lineNumber":899,"sourceCode":"\n            //If the StreamInfo exists we go on to check if correct transform has been\n            //applied to the Stream\n\n            DataSpaceManager dsm = _root.GetDataSpaceManager();\n\n            List<IDataTransform> transforms = dsm.GetTransformsForStreamInfo(siPackage);\n\n            RightsManagementEncryptionTransform rmet = null;\n\n            foreach (IDataTransform dataTransform in transforms)\n            {\n                if (dataTransform.TransformIdentifier is string id &&\n                    string.Equals(id, RightsManagementEncryptionTransform.ClassTransformIdentifier, StringComparison.OrdinalIgnoreCase))\n                {\n                    // Do not allow more than one RM Transform\n                    if (rmet != null)\n                    {\n                        throw new FileFormatException(SR.MultipleRightsManagementEncryptionTransformFound);\n                    }\n\n                    rmet = dataTransform as RightsManagementEncryptionTransform;\n                }\n            }\n\n            if (rmet == null)\n            {\n                throw new FileFormatException(SR.RightsManagementEncryptionTransformNotFound);\n            }\n\n            //\n            //  There is no reason to further push initialization of the Rights Management \n            //  data (parsing publish / use license). It will add unnecessary costs to the \n            //  scenarios where RM license are not relevant, for example indexing and \n            //  working with document properties            \n            //\n            ","sourceCodeStart":881,"sourceCodeEnd":917,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/EncryptedPackage.cs#L881-L917","documentation":"While enumerating the data-space transforms during Open, more than one transform with the RightsManagementEncryptionTransform identifier was found. The format allows at most one RM transform, so a FileFormatException is thrown as the document structure is invalid.","triggerScenarios":"EncryptedPackageEnvelope.Open on a compound file whose DataSpaceManager lists two or more transforms whose TransformIdentifier equals RightsManagementEncryptionTransform.ClassTransformIdentifier — typically from corrupted or hand-edited files, or files produced by buggy third-party writers.","commonSituations":"Files tampered with or merged incorrectly; files written by non-Microsoft producers of RM-protected content; low-level storage corruption after disk issues.","solutions":["Regenerate the document with a correct producer (save again via the legitimate RM-protecting application)","Treat the file as corrupt: detect FileFormatException on Open and reject/fallback, do not attempt repair of the transform table","If programmatically constructing files, never register the RM transform more than once in the DataSpaceManager"],"exampleFix":"// before\nvar env = EncryptedPackageEnvelope.Open(path); // throws on double RM transform\n// after\ntry { var env = EncryptedPackageEnvelope.Open(path); }\ncatch (FileFormatException ex) { LogCorruptPackage(path, ex); } // mark file unusable","handlingStrategy":"try-catch","validationCode":"// Inspect data-space transforms before open\nvar dsm = StorageInfo.Open(path).GetDataSpaceManager();\nint rmCount = dsm.GetDataTransforms().Count(t => string.Equals(t.TransformIdentifier, RightsManagementEncryptionTransform.ClassTransformIdentifier, StringComparison.OrdinalIgnoreCase));\nif (rmCount > 1) throw new InvalidDataException(\"Multiple RM transforms.\");","typeGuard":null,"tryCatchPattern":"try { var env = EncryptedPackageEnvelope.Open(path); }\ncatch (FileFormatException ex) { LogCorrupt(path, ex); RejectFile(path); }","preventionTips":["Never register the RM transform more than once when building data spaces","Reject/hand-off files flagged as corrupt rather than attempting in-place repair","Resave protected documents with the original producer to normalize structure"],"tags":["wpf","packaging","corruption","rights-management"],"backgroundTag":"schema-validation-failed","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"}