{"record":{"id":"be645e87166d9770","repo":"dotnet/wpf","slug":"sr-serializerprovidernotregistered","errorCode":null,"errorMessage":"SR.SerializerProviderNotRegistered","messagePattern":"SR\\.SerializerProviderNotRegistered","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"warning","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Serialization/SerializerProvider.cs","lineNumber":105,"sourceCode":"        /// <summary>\n        /// Un-Registers the serializer plug-in identified by serializerDescriptor in the registry\n        /// </summary>\n        /// <remarks>\n        ///     Removes a previously installed plug-n serialiazer from the registry\n        ///\n        ///     This method currently requires full trust to run.\n        /// </remarks>\n        public static void UnregisterSerializer(SerializerDescriptor serializerDescriptor)\n        {\n\n            ArgumentNullException.ThrowIfNull(serializerDescriptor);\n\n            RegistryKey plugIns = _rootKey.CreateSubKey(_registryPath);\n            string serializerKey = $\"{serializerDescriptor.DisplayName}/{serializerDescriptor.AssemblyName}/{serializerDescriptor.AssemblyVersion}/{serializerDescriptor.WinFXVersion}\";\n\n            if (plugIns.OpenSubKey(serializerKey) == null)\n            {\n                throw new ArgumentException(SR.SerializerProviderNotRegistered, serializerKey);\n            }\n\n            plugIns.DeleteSubKeyTree(serializerKey);\n        }\n\n        /// <summary>\n        /// Create a SerializerWriter identified by the passed in SerializerDescriptor on the passed in stream\n        /// </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;","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Serialization/SerializerProvider.cs#L87-L123","documentation":"SerializerProvider.UnregisterSerializer deletes the registry subkey '{DisplayName}/{AssemblyName}/{AssemblyVersion}/{WinFXVersion}' for the given descriptor. If no such key exists, it throws ArgumentException (SR.SerializerProviderNotRegistered) with the serializer key as paramName — you cannot unregister a serializer that was never registered.","triggerScenarios":"Calling UnregisterSerializer with a descriptor whose registration key is absent: never registered, already uninstalled, or registered with different DisplayName/AssemblyName/AssemblyVersion/WinFXVersion values than the descriptor passed now.","commonSituations":"Uninstaller removing a plugin twice; unregistration using a descriptor whose version differs from the one originally registered; cleaning a machine where the plugin registry was manually edited.","solutions":["Verify registration first (open the registry key or attempt RegisterSerializer semantics) before calling UnregisterSerializer","Catch ArgumentException and treat 'not registered' as a no-op success in uninstall code","Ensure the descriptor passed matches the original registration exactly (same DisplayName, AssemblyName, AssemblyVersion, WinFXVersion)","Manually delete the stale plugin subkey under the serializer plugins registry path if descriptors cannot be reconstructed"],"exampleFix":"// before\nSerializerProvider.UnregisterSerializer(descriptor); // throws if absent\n// after\ntry { SerializerProvider.UnregisterSerializer(descriptor); }\ncatch (ArgumentException) { /* not registered - nothing to do */ }","handlingStrategy":"try-catch","validationCode":"using Microsoft.Win32;\nbool SerializerKeyExists(RegistryKey root, string pluginsPath, SerializerDescriptor d) {\n    using var plugins = root.OpenSubKey(pluginsPath);\n    var key = $\"{d.DisplayName}/{d.AssemblyName}/{d.AssemblyVersion}/{d.WinFXVersion}\";\n    using var k = plugins?.OpenSubKey(key);\n    return k != null;\n}","typeGuard":null,"tryCatchPattern":"try { SerializerProvider.UnregisterSerializer(descriptor); }\ncatch (ArgumentException) { /* not registered - no-op */ }","preventionTips":["Check for the key before unregistering","Reuse the exact descriptor (same version) used at registration","Make uninstallers idempotent by swallowing 'not registered' errors"],"tags":["wpf","serializer","registry","not-registered"],"backgroundTag":"record-not-found","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}