dotnet/wpf · error · FileFormatException
Feature name in the transform's primary stream is
Error message
Feature name in the transform's primary stream is '{0}', but expected '{1}'. What it means
This FileFormatException is thrown when the FeatureIdentifier stored in a transform's primary stream does not match the expected DataSpaceVersionIdentifier. The transform metadata belongs to an unknown or different feature, so the library refuses to process it. Comparison is case-insensitive ordinal per the data-space spec.
Solutions
- Open the package with the software version that wrote the transform (the identifier is product-specific).
- Re-save the package from the original application so the expected feature identifier is written.
- Inspect the transform's primary stream to confirm the mismatched identifier string.
- Catch FileFormatException and report an unsupported/incompatible package format to the user.
Defensive patterns
Strategy: try-catch
Validate before calling
// Only accept packages produced by the expected writer/version:
if (!IsFromTrustedProducer(path)) throw new InvalidDataException("Package produced by an unsupported implementation."); Type guard
bool UsesExpectedFeatureIdentifier(string featureId, string expectedId) => string.Equals(featureId, expectedId, StringComparison.OrdinalIgnoreCase);
Try / catch
try { package = Package.Open(path); }
catch (FileFormatException ex) when (ex.Message.Contains("Feature name")) { Console.Error.WriteLine($"Unsupported transform feature: {ex.Message}"); throw; } Prevention
- Open packages with the same product/version that wrote them.
- Re-export packages to a supported format before cross-tool consumption.
- Log the feature identifier from the exception for diagnostics.
When it happens
Trigger: Opening a package whose transform's primary stream ("/_metadata/DataSpaces/TransformInfo/...") records a FeatureIdentifier other than the expected DataSpace version identifier; raised in DataSpaceManager while reading the transform's file format version block.
Common situations: Packages written by other/older implementations using different transform feature identifiers, hand-edited or repackaged files where the identifier was changed, or reading a file that mixes transform formats.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- File contains data in format version
- SR.Format(SR.InvalidTransformFeatureName…
- DataSpace map entry is not valid.
- Document does not contain a package.
- Document does not contain any rights management-protected…
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/1a2979596210e6f9.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/DataSpaceManager.cs:1594
/// If the format version information in the stream is corrupt.
/// </exception>
private void ReadDataSpaceVersionInformation(StorageInfo dataSpaceStorage)
{
if (_fileFormatVersion == null)
{
if (dataSpaceStorage.StreamExists( DataSpaceVersionName ))
{
StreamInfo versionStreamInfo = dataSpaceStorage.GetStreamInfo( DataSpaceVersionName );
using (Stream versionStream = versionStreamInfo.GetStream(FileMode.Open))
{
_fileFormatVersion = FormatVersion.LoadFromStream(versionStream);
// Transform Identifier: we preserve casing, but do case-insensitive comparison
//Case-insensitive comparison. As per recommendations, we convert both strings
//to Upper case and then compare with StringComparison.Ordinal
if (!string.Equals(_fileFormatVersion.FeatureIdentifier, DataSpaceVersionIdentifier, StringComparison.OrdinalIgnoreCase))
{
throw new FileFormatException(
SR.Format(SR.InvalidTransformFeatureName,
_fileFormatVersion.FeatureIdentifier,
DataSpaceVersionIdentifier));
}
// If we ever write this version number out again, we will want to record
// the fact that it was done by the current version of the Dataspace software.
_fileFormatVersion.WriterVersion = DataSpaceCurrentWriterVersion;
}
}
}
}
/// <summary>
/// If the DataSpace version information was not present in the file, we initialize it with the
/// values for the current DataSpace software.
/// If the information was present we should have already read it as a part of the ReadDataSpaceMap.
/// </summary>
private void EnsureDataSpaceVersionInformation()View on GitHub (pinned to 81131a70a4)