{"record":{"id":"0a5b782d1ed25869","repo":"dotnet/wpf","slug":"sr-serializerprovidercannotload","errorCode":null,"errorMessage":"SR.SerializerProviderCannotLoad","messagePattern":"SR\\.SerializerProviderCannotLoad","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Serialization/SerializerProvider.cs","lineNumber":158,"sourceCode":"                    found = true;\n                    break;\n                }\n            }\n\n            if (!found)\n            {\n                throw new ArgumentException(SR.SerializerProviderUnknownSerializer, serializerKey);\n            }\n\n            try\n            {\n                ISerializerFactory factory = serializerDescriptor.CreateSerializerFactory();\n\n                serializerWriter = factory.CreateSerializerWriter(stream);\n            }\n            catch (FileNotFoundException)\n            {\n                throw new ArgumentException(SR.SerializerProviderCannotLoad, serializerDescriptor.DisplayName);\n            }\n            catch (FileLoadException)\n            {\n                throw new ArgumentException(SR.SerializerProviderCannotLoad, serializerDescriptor.DisplayName);\n            }\n            catch (BadImageFormatException)\n            {\n                throw new ArgumentException(SR.SerializerProviderCannotLoad, serializerDescriptor.DisplayName);\n            }\n            catch (MissingMethodException)\n            {\n                throw new ArgumentException(SR.SerializerProviderCannotLoad, serializerDescriptor.DisplayName);\n            }\n\n            return serializerWriter;\n        }\n\n        #endregion","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Serialization/SerializerProvider.cs#L140-L176","documentation":"SerializerProvider.CreateSerializerWriter wraps factory creation and wraps FileNotFoundException in an ArgumentException with SR.SerializerProviderCannotLoad. This means the serializer plug-in assembly (named by serializerDescriptor.DisplayName) could not be found on disk when CreateSerializerFactory attempted to load it. The plug-in descriptor exists in the registry but the underlying DLL is missing.","triggerScenarios":"Calling CreateSerializerWriter with a descriptor whose factory creation (serializerDescriptor.CreateSerializerFactory / Assembly.Load) throws FileNotFoundException because the plug-in assembly file is absent.","commonSituations":"A registered WPF serializer plug-in was deleted or moved after registration; partial uninstall left stale registry entries; deployment to a machine missing the plug-in DLL; mismatched x86/x64 install paths.","solutions":["Reinstall or repair the serializer plug-in so its assembly is present at the registered location.","Remove the stale plug-in registration so it no longer appears in InstalledSerializers.","Pick a different installed serializer from InstalledSerializers whose assembly loads successfully.","Catch ArgumentException (paramName = DisplayName) and fall back to the built-in XPS serializer."],"exampleFix":"// before\nvar writer = SerializerProvider.CreateSerializerWriter(stream, descriptor);\n// after\ntry\n{\n    writer = SerializerProvider.CreateSerializerWriter(stream, descriptor);\n}\ncatch (ArgumentException ex)\n{\n    throw new InvalidOperationException($\"Serializer '{descriptor.DisplayName}' could not be loaded: {ex.Message}\", ex);\n}","handlingStrategy":"try-catch","validationCode":"static bool TryGetFactory(SerializerDescriptor d, out ISerializerFactory f)\n{ try { f = d.CreateSerializerFactory(); return true; } catch (FileNotFoundException) { f = null; return false; } }","typeGuard":"null","tryCatchPattern":"try { writer = SerializerProvider.CreateSerializerWriter(stream, descriptor); }\ncatch (ArgumentException ex) when (ex.ParamName == descriptor.DisplayName)\n{ log.Error($\"Serializer assembly for '{descriptor.DisplayName}' is missing.\", ex); writer = UseBuiltInXps(stream); }","preventionTips":["Repair/reinstall plug-ins after OS or framework servicing","Prune stale plug-in registrations","Keep a built-in XPS fallback in code"],"tags":["wpf","serialization","assembly-load","file-not-found"],"backgroundTag":"missing-dependency","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"}