{"record":{"id":"1a2979596210e6f9","repo":"dotnet/wpf","slug":"feature-name-in-the-transform-s-primary-stream-is-0-but","errorCode":null,"errorMessage":"Feature name in the transform's primary stream is '{0}', but expected '{1}'.","messagePattern":"Feature name in the transform's primary stream is '(.+?)', but expected '(.+?)'\\.","errorType":"exception","errorClass":"FileFormatException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/DataSpaceManager.cs","lineNumber":1594,"sourceCode":"    /// If the format version information in the stream is corrupt.\n    /// </exception>\n    private void ReadDataSpaceVersionInformation(StorageInfo dataSpaceStorage)\n    {\n        if (_fileFormatVersion == null)\n        {\n            if (dataSpaceStorage.StreamExists( DataSpaceVersionName ))\n            {\n                StreamInfo versionStreamInfo = dataSpaceStorage.GetStreamInfo( DataSpaceVersionName );\n                using (Stream versionStream = versionStreamInfo.GetStream(FileMode.Open))\n                {\n                    _fileFormatVersion = FormatVersion.LoadFromStream(versionStream);\n\n                    // Transform Identifier: we preserve casing, but do case-insensitive comparison\n                    //Case-insensitive comparison. As per recommendations, we convert both strings\n                    //to Upper case and then compare with StringComparison.Ordinal\n                    if (!string.Equals(_fileFormatVersion.FeatureIdentifier, DataSpaceVersionIdentifier, StringComparison.OrdinalIgnoreCase))\n                    {\n                        throw new FileFormatException(\n                                            SR.Format(SR.InvalidTransformFeatureName,\n                                            _fileFormatVersion.FeatureIdentifier,\n                                            DataSpaceVersionIdentifier));\n                    }\n                    // If we ever write this version number out again, we will want to record\n                    // the fact that it was done by the current version of the Dataspace software.\n                    _fileFormatVersion.WriterVersion = DataSpaceCurrentWriterVersion;\n                }\n            }\n        }\n    }\n\n    /// <summary>\n    /// If the DataSpace version information was not present in the file, we initialize it with the\n    /// values for the current DataSpace software.\n    /// If the information was present we should have already read it as a part of the ReadDataSpaceMap.\n    /// </summary>\n    private void EnsureDataSpaceVersionInformation()","sourceCodeStart":1576,"sourceCodeEnd":1612,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/DataSpaceManager.cs#L1576-L1612","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Only accept packages produced by the expected writer/version:\nif (!IsFromTrustedProducer(path)) throw new InvalidDataException(\"Package produced by an unsupported implementation.\");","typeGuard":"bool UsesExpectedFeatureIdentifier(string featureId, string expectedId) => string.Equals(featureId, expectedId, StringComparison.OrdinalIgnoreCase);","tryCatchPattern":"try { package = Package.Open(path); }\ncatch (FileFormatException ex) when (ex.Message.Contains(\"Feature name\")) { Console.Error.WriteLine($\"Unsupported transform feature: {ex.Message}\"); throw; }","preventionTips":["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."],"tags":["file-format","version-mismatch","transform-metadata"],"backgroundTag":"unsupported-operation","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"}