{"record":{"id":"5f85f66a64bf23c0","repo":"dotnet/wpf","slug":"sr-rmproviderexceptionnopublishlicense","errorCode":null,"errorMessage":"SR.RMProviderExceptionNoPublishLicense","messagePattern":"SR\\.RMProviderExceptionNoPublishLicense","errorType":"exception","errorClass":"FileFormatException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementProvider.cs","lineNumber":1278,"sourceCode":"\n    /// <summary>\n    /// Initializes the necessary member variables.  This can be called more\n    /// than once without ill effect.\n    /// </summary>\n    private void InitializeMembers()\n    {\n        if (_encryptedPackageEnvelope != null &&\n            _publishLicenseFromEnvelope == null)\n        {\n            RightsManagementInformation rmInfo =\n                _encryptedPackageEnvelope.RightsManagementInformation;\n            PublishLicense publishLicense = null;\n\n            publishLicense = rmInfo.LoadPublishLicense();\n\n            if (publishLicense == null)\n            {\n                throw new FileFormatException(\n                    SR.RMProviderExceptionNoPublishLicense);\n            }\n\n            _publishLicenseFromEnvelope = publishLicense;\n            CurrentPublishLicense = publishLicense;\n        }\n    }\n\n    /// <summary>\n    /// Cleans up the SecureEnvironment member.\n    /// </summary>\n    private void CleanUpSecureEnvironment()\n    {\n        _secureEnvironment?.Dispose();\n        _secureEnvironment = null;\n    }\n\n    /// <summary>","sourceCodeStart":1260,"sourceCodeEnd":1296,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementProvider.cs#L1260-L1296","documentation":"During InitializeMembers, the provider loads the publish license from the rights management envelope (rmInfo.LoadPublishLicense()); when it returns null a FileFormatException is thrown with SR.RMProviderExceptionNoPublishLicense. The protected package is malformed: the mandatory publish license is missing. This runs during IsProtected, InitializeEnvironment, and SetEncryptedPackage paths.","triggerScenarios":"Opening/initializing a rights-managed compound document whose envelope contains no publish license — e.g., LoadPublishLicense returns null because the package part is absent, corrupt, or was stripped by a non-conforming producer.","commonSituations":"Opening a document produced by a buggy or third-party RM writer, a partially copied/truncated .xps/.baml protected package, or a file modified by tooling that removed RM metadata.","solutions":["Verify the document is a complete, valid rights-managed package; re-obtain the original file.","Regenerate/re-save the document with the original application to embed a valid publish license.","Check that the envelope's RM metadata parts exist and are readable on disk (not blocked/truncated by sync or transfer tools).","If you control the producer, fix the writer so a PublishLicense is always embedded when protecting a document."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { provider.SetEncryptedPackage(packageStream); }\ncatch (FileFormatException) { /* treat document as corrupt/invalid RM package; ask user for original file */ }","preventionTips":["Verify RM package integrity (complete file, correct size) before opening.","Never strip or hand-edit RM metadata parts in the container.","Distribute protected documents only via transfer methods that preserve bytes (no lossy conversion)."],"tags":["wpf","rights-management","file-format"],"backgroundTag":"resource-not-found","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"}