dotnet/wpf · error · ArgumentException

SR.SerializerProviderCannotLoad

Error message

SR.SerializerProviderCannotLoad

What it means

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.

Solutions

  1. Reinstall or repair the serializer plug-in so its assembly is present at the registered location.
  2. Remove the stale plug-in registration so it no longer appears in InstalledSerializers.
  3. Pick a different installed serializer from InstalledSerializers whose assembly loads successfully.
  4. Catch ArgumentException (paramName = DisplayName) and fall back to the built-in XPS serializer.

Example fix

// before
var writer = SerializerProvider.CreateSerializerWriter(stream, descriptor);
// after
try
{
    writer = SerializerProvider.CreateSerializerWriter(stream, descriptor);
}
catch (ArgumentException ex)
{
    throw new InvalidOperationException($"Serializer '{descriptor.DisplayName}' could not be loaded: {ex.Message}", ex);
}
Defensive patterns

Strategy: try-catch

Validate before calling

static bool TryGetFactory(SerializerDescriptor d, out ISerializerFactory f)
{ try { f = d.CreateSerializerFactory(); return true; } catch (FileNotFoundException) { f = null; return false; } }

Type guard

null

Try / catch

try { writer = SerializerProvider.CreateSerializerWriter(stream, descriptor); }
catch (ArgumentException ex) when (ex.ParamName == descriptor.DisplayName)
{ log.Error($"Serializer assembly for '{descriptor.DisplayName}' is missing.", ex); writer = UseBuiltInXps(stream); }

Prevention

When it happens

Trigger: Calling CreateSerializerWriter with a descriptor whose factory creation (serializerDescriptor.CreateSerializerFactory / Assembly.Load) throws FileNotFoundException because the plug-in assembly file is absent.

Common situations: 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.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/0a5b782d1ed25869. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Serialization/SerializerProvider.cs:158

                    found = true;
                    break;
                }
            }

            if (!found)
            {
                throw new ArgumentException(SR.SerializerProviderUnknownSerializer, serializerKey);
            }

            try
            {
                ISerializerFactory factory = serializerDescriptor.CreateSerializerFactory();

                serializerWriter = factory.CreateSerializerWriter(stream);
            }
            catch (FileNotFoundException)
            {
                throw new ArgumentException(SR.SerializerProviderCannotLoad, serializerDescriptor.DisplayName);
            }
            catch (FileLoadException)
            {
                throw new ArgumentException(SR.SerializerProviderCannotLoad, serializerDescriptor.DisplayName);
            }
            catch (BadImageFormatException)
            {
                throw new ArgumentException(SR.SerializerProviderCannotLoad, serializerDescriptor.DisplayName);
            }
            catch (MissingMethodException)
            {
                throw new ArgumentException(SR.SerializerProviderCannotLoad, serializerDescriptor.DisplayName);
            }

            return serializerWriter;
        }

        #endregion

View on GitHub (pinned to 81131a70a4)