{"record":{"id":"ff441ccd0a5dff74","repo":"dotnet/wpf","slug":"sr-format-sr-invalidtransformfeaturename-fileversion","errorCode":null,"errorMessage":"SR.Format(SR.InvalidTransformFeatureName, _fileVersion.FeatureIdentifier, _codeVersion.FeatureIdentifier)","messagePattern":"SR\\.Format\\(SR\\.InvalidTransformFeatureName, _fileVersion\\.FeatureIdentifier, _codeVersion\\.FeatureIdentifier\\)","errorType":"exception","errorClass":"FileFormatException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/VersionedStreamOwner.cs","lineNumber":400,"sourceCode":"                // which the stream belongs. The \"logical\" stream object handed to us by the\n                // compound file begins -after- this stream header, so when we seek to the\n                // \"beginning\" of this stream, we are actually seeking to the location after\n                // the stream header, where the instance data starts.\n                //\n                BaseStream.Seek(0, SeekOrigin.Begin);\n\n                //\n                // The instance data starts with format version information for this transform.\n                //\n                _fileVersion = FormatVersion.LoadFromStream(BaseStream);\n\n                //\n                // Ensure that the feature name is as expected.\n                //\n                // NOTE: We preserve case, but do case-insensitive comparison.\n                if (!string.Equals(_fileVersion.FeatureIdentifier, _codeVersion.FeatureIdentifier, StringComparison.OrdinalIgnoreCase))\n                {\n                    throw new FileFormatException(\n                                    SR.Format(\n                                        SR.InvalidTransformFeatureName,\n                                        _fileVersion.FeatureIdentifier,\n                                        _codeVersion.FeatureIdentifier\n                                        )\n                                    );\n                }\n\n                _dataOffset = BaseStream.Position;\n            }\n        }\n\n        //------------------------------------------------------\n        //\n        //  Private Fields\n        //\n        //------------------------------------------------------\n        private bool            _writeOccurred;     // did one of our streams get written to?","sourceCodeStart":382,"sourceCodeEnd":418,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/VersionedStreamOwner.cs#L382-L418","documentation":"EnsureParsed compares the feature identifier stored in the stream's version header against the identifier expected by the code's known version (_codeVersion). The comparison is case-insensitive; a mismatch means the stream belongs to a different transform, so a FileFormatException naming both identifiers is thrown.","triggerScenarios":"Opening a compound-file stream whose serialized version header carries a FeatureIdentifier that does not (case-insensitively) equal the transform's expected FeatureIdentifier, during ReadAttempt/WriteAttempt/IsReadable/IsUpdatable.","commonSituations":"Files produced by a different compression/transform implementation or a different product version; corrupted or renamed header fields; opening a non-XPS compound file that coincidentally has a version block.","solutions":["Verify the file was produced by the same transform (check the two identifiers in the exception message).","Regenerate or re-save the package with the correct tool/runtime version.","Do not hand-edit the version header; restore the file from a trusted source.","If supporting multiple transforms, route the stream to the correct VersionedStreamOwner based on the header identifier before parsing."],"exampleFix":"// before: blindly opening any compound-file stream\nvar vs = new VersionedStreamOwner(stream, codeVersion);\nvs.ReadAttempt(buffer, 0, len);\n// after: pre-check the transform identity where possible, or catch and report\ntry { vs.ReadAttempt(buffer, 0, len); }\ncatch (FileFormatException e)\n{ throw new InvalidDataException($\"Stream transform mismatch: {e.Message}\", e); }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"static bool SameTransform(string fileFeatureId, string codeFeatureId) =>\n    string.Equals(fileFeatureId, codeFeatureId, StringComparison.OrdinalIgnoreCase);","tryCatchPattern":"try { owner.ReadAttempt(buffer, 0, len); }\ncatch (FileFormatException e) { throw new InvalidDataException($\"Container transform mismatch: {e.Message}\", e); }","preventionTips":["Check the two feature identifiers in the message to identify what produced the file","Route streams to the correct transform based on the header identifier before parsing","Keep writer and reader transform versions in sync across deployments"],"tags":["wpf","packaging","version-mismatch","file-format","transform"],"backgroundTag":"incompatible-source-type","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"}