dotnet/wpf · error · ArgumentException

SR.SerializerProviderUnknownSerializer

Error message

SR.SerializerProviderUnknownSerializer

What it means

SerializerProvider.CreateSerializerWriter throws ArgumentException with SR.SerializerProviderUnknownSerializer when the supplied SerializerDescriptor does not match any currently installed serializer. Even if the descriptor looks loadable, it must be found in InstalledSerializers (matched by DisplayName/AssemblyName/version key) before its factory can be used. The descriptor key is passed as paramName.

Solutions

  1. Only use descriptors taken from SerializerProvider.InstalledSerializers; verify the descriptor is in that list before calling CreateSerializerWriter.
  2. Check the plug-in serializer is installed and registered on the target machine (Program Files/WPF plug-in registry entries).
  3. Fall back to the built-in XPS serializer (e.g. XpsDocument/XpsSerializationManager) instead of a third-party plug-in.
  4. Catch ArgumentException and inform the user the requested serializer is not installed.

Example fix

// before
var writer = SerializerProvider.CreateSerializerWriter(stream, customDescriptor);
// after
var installed = SerializerProvider.InstalledSerializers
    .FirstOrDefault(s => s.AssemblyName == customDescriptor.AssemblyName && s.IsLoadable);
if (installed == null)
    throw new InvalidOperationException("Requested serializer plug-in is not installed.");
var writer = SerializerProvider.CreateSerializerWriter(stream, installed);
Defensive patterns

Strategy: validation

Validate before calling

bool installed = SerializerProvider.InstalledSerializers
    .Any(s => s.AssemblyName == descriptor.AssemblyName
           && s.AssemblyVersion == descriptor.AssemblyVersion);
if (!installed) throw new InvalidOperationException("Serializer plug-in is not installed on this machine.");

Type guard

static SerializerDescriptor FindInstalled(string assemblyName) =>
    SerializerProvider.InstalledSerializers.FirstOrDefault(s => s.AssemblyName == assemblyName && s.IsLoadable);

Try / catch

try { writer = SerializerProvider.CreateSerializerWriter(stream, descriptor); }
catch (ArgumentException ex) { throw new InvalidOperationException($"Unknown serializer: {descriptor.DisplayName}", ex); }

Prevention

When it happens

Trigger: Calling SerializerProvider.CreateSerializerWriter(Stream, SerializerDescriptor) with a descriptor that is loadable but is not present in the InstalledSerializers enumeration (the foreach loop over InstalledSerializers never sets found=true).

Common situations: Manually constructing a SerializerDescriptor for a plug-in that is not registered/installed on the machine; the plug-in was uninstalled or its registration moved between enumerating serializers and using one; targeting a serializer on a machine where it was never deployed.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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

Appendix: source

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

            if (!serializerDescriptor.IsLoadable)
            {
                throw new ArgumentException(SR.SerializerProviderWrongVersion, serializerKey);
            }
            ArgumentNullException.ThrowIfNull(stream);

            bool found = false;
            foreach (SerializerDescriptor sd in InstalledSerializers)
            {
                if (sd.Equals(serializerDescriptor))
                {
                    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)
            {

View on GitHub (pinned to 81131a70a4)