{"record":{"id":"332df2d770c27ed0","repo":"dotnet/wpf","slug":"sr-serializerproviderwrongversion","errorCode":null,"errorMessage":"SR.SerializerProviderWrongVersion","messagePattern":"SR\\.SerializerProviderWrongVersion","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Serialization/SerializerProvider.cs","lineNumber":131,"sourceCode":"        /// </summary>\n        /// <remarks>\n        ///     With a SerializerProvider (which requires full trust to ctor) and a SerializerDescriptor (which requires\n        ///     full trust to obtain) create a SerializerWriter\n        ///\n        ///     This method currently requires full trust to run.\n        /// </remarks>\n        public SerializerWriter CreateSerializerWriter(SerializerDescriptor serializerDescriptor, Stream stream)\n        {\n\n            SerializerWriter serializerWriter = null;\n\n            ArgumentNullException.ThrowIfNull(serializerDescriptor);\n\n            string serializerKey = $\"{serializerDescriptor.DisplayName}/{serializerDescriptor.AssemblyName}/{serializerDescriptor.AssemblyVersion}/{serializerDescriptor.WinFXVersion}\";\n\n            if (!serializerDescriptor.IsLoadable)\n            {\n                throw new ArgumentException(SR.SerializerProviderWrongVersion, serializerKey);\n            }\n            ArgumentNullException.ThrowIfNull(stream);\n\n            bool found = false;\n            foreach (SerializerDescriptor sd in InstalledSerializers)\n            {\n                if (sd.Equals(serializerDescriptor))\n                {\n                    found = true;\n                    break;\n                }\n            }\n\n            if (!found)\n            {\n                throw new ArgumentException(SR.SerializerProviderUnknownSerializer, serializerKey);\n            }\n","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Serialization/SerializerProvider.cs#L113-L149","documentation":"SerializerProvider.CreateSerializerWriter throws ArgumentException with SR.SerializerProviderWrongVersion when the supplied SerializerDescriptor is not loadable, i.e. its WinFXVersion does not match the current installed serializer/plug-in framework version. The library refuses to instantiate a plug-in serializer that was built against a different WPF framework version, since it could not be safely loaded. The invalid descriptor key (DisplayName/AssemblyName/AssemblyVersion/WinFXVersion) is passed as paramName.","triggerScenarios":"Calling SerializerProvider.CreateSerializerWriter(Stream, SerializerDescriptor) with a SerializerDescriptor whose IsLoadable property is false - typically because the descriptor's WinFXVersion differs from the version SerializerProvider supports.","commonSituations":"Enumerating installed serializers and passing a stale descriptor built against an older .NET/WPF (WinFX) version; a plug-in serializer DLL was upgraded or downgraded so its declared framework version no longer matches the runtime; hard-coding a SerializerDescriptor instead of using InstalledSerializers.","solutions":["Check serializerDescriptor.IsLoadable before calling CreateSerializerWriter and skip or refresh the descriptor if false.","Re-obtain descriptors from SerializerProvider.InstalledSerializers so versions reflect the currently installed plug-ins.","Rebuild/re-register the plug-in serializer against the current WinFX/.NET Framework version so its WinFXVersion matches.","Catch ArgumentException and surface which serializer key failed using the paramName."],"exampleFix":"// before\nvar writer = SerializerProvider.CreateSerializerWriter(stream, myDescriptor);\n// after\nif (myDescriptor.IsLoadable)\n{\n    var writer = SerializerProvider.CreateSerializerWriter(stream, myDescriptor);\n}\nelse\n{\n    throw new InvalidOperationException($\"Serializer '{myDescriptor.DisplayName}' is not loadable for this framework version.\");\n}","handlingStrategy":"validation","validationCode":"if (descriptor == null) throw new ArgumentNullException(nameof(descriptor));\nif (!descriptor.IsLoadable)\n    throw new InvalidOperationException($\"Serializer '{descriptor.DisplayName}' ({descriptor.WinFXVersion}) is not loadable in this runtime.\");","typeGuard":"static bool IsUsableSerializer(SerializerDescriptor d) => d != null && d.IsLoadable;","tryCatchPattern":"try { writer = SerializerProvider.CreateSerializerWriter(stream, descriptor); }\ncatch (ArgumentException ex) { /* ex.ParamName is the serializer key */ throw new InvalidOperationException($\"Serializer version mismatch for {descriptor.DisplayName}.\", ex); }","preventionTips":["Always source descriptors from SerializerProvider.InstalledSerializers","Filter on IsLoadable before use","Re-check descriptors after plug-in installs/upgrades"],"tags":["wpf","serialization","version-mismatch","plugin"],"backgroundTag":"invalid-argument-value","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"}