dotnet/wpf · error · FileFormatException
Document does not contain any rights management-protected…
Error message
Document does not contain any rights management-protected streams.
What it means
After scanning all transforms in the data space, no RightsManagementEncryptionTransform was found, meaning the document has no RM-protected streams. Open of an EncryptedPackageEnvelope requires at least one, so FileFormatException is thrown.
Solutions
- Open unprotected packages with Package.Open / OpfXpsHelper instead of EncryptedPackageEnvelope.Open
- Check for the RM transform (e.g. via GetDataSpaceManager) before attempting RM-specific open
- If the file should be protected, re-protect it by creating a new EncryptedPackageEnvelope from the plain package
Example fix
// before
var env = EncryptedPackageEnvelope.Open(path); // throws if not RM-protected
// after
if (IsRightsManaged(path)) { var env = EncryptedPackageEnvelope.Open(path); }
else { var pkg = Package.Open(path); } Defensive patterns
Strategy: validation
Validate before calling
var dsm = StorageInfo.Open(path).GetDataSpaceManager();
bool hasRm = dsm.GetDataTransforms().Any(t => string.Equals(t.TransformIdentifier, RightsManagementEncryptionTransform.ClassTransformIdentifier, StringComparison.OrdinalIgnoreCase));
if (!hasRm) { /* open as plain package instead */ } Try / catch
try { var env = EncryptedPackageEnvelope.Open(path); }
catch (FileFormatException) { var pkg = Package.Open(path); /* unprotected path */ } Prevention
- Check for the RM transform before choosing the RM open API
- Use Package.Open for unprotected packages
- Re-protect plain packages via EncryptedPackageEnvelope.Create when RM is required
When it happens
Trigger: EncryptedPackageEnvelope.Open on a compound file that contains a package stream but whose DataSpaceManager has no transform matching the RM class identifier — e.g. a plain (unprotected) XPS/package stored in a compound file, or a file whose transform entries were stripped.
Common situations: Opening a normal OPC/XPS package in compound-file form with the RM-aware Open API; opening a file whose encryption transform was removed by another tool; wrong API chosen for unprotected documents.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Document does not contain a package.
- SR.Format(SR.PublishLicenseStreamHeaderTooLong, headerLen…
- SR.PublishLicenseStreamCorrupt
- Document contains multiple Rights Management Encryption…
- Signature structures are corrupted in this package.
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/836a624102d99f7c.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/EncryptedPackage.cs:908
foreach (IDataTransform dataTransform in transforms)
{
if (dataTransform.TransformIdentifier is string id &&
string.Equals(id, RightsManagementEncryptionTransform.ClassTransformIdentifier, StringComparison.OrdinalIgnoreCase))
{
// Do not allow more than one RM Transform
if (rmet != null)
{
throw new FileFormatException(SR.MultipleRightsManagementEncryptionTransformFound);
}
rmet = dataTransform as RightsManagementEncryptionTransform;
}
}
if (rmet == null)
{
throw new FileFormatException(SR.RightsManagementEncryptionTransformNotFound);
}
//
// There is no reason to further push initialization of the Rights Management
// data (parsing publish / use license). It will add unnecessary costs to the
// scenarios where RM license are not relevant, for example indexing and
// working with document properties
//
//
// Make the rights management information stored in the compound file
// available to the application through the RightsManagementInformation
// property.
//
_rmi = new RightsManagementInformation(rmet);
}
/// <summary>View on GitHub (pinned to 81131a70a4)