dotnet/wpf · error · ArgumentException
SR.SerializerProviderWrongVersion
Error message
SR.SerializerProviderWrongVersion
What it means
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.
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.
Example fix
// before
var writer = SerializerProvider.CreateSerializerWriter(stream, myDescriptor);
// after
if (myDescriptor.IsLoadable)
{
var writer = SerializerProvider.CreateSerializerWriter(stream, myDescriptor);
}
else
{
throw new InvalidOperationException($"Serializer '{myDescriptor.DisplayName}' is not loadable for this framework version.");
} Defensive patterns
Strategy: validation
Validate before calling
if (descriptor == null) throw new ArgumentNullException(nameof(descriptor));
if (!descriptor.IsLoadable)
throw new InvalidOperationException($"Serializer '{descriptor.DisplayName}' ({descriptor.WinFXVersion}) is not loadable in this runtime."); Type guard
static bool IsUsableSerializer(SerializerDescriptor d) => d != null && d.IsLoadable;
Try / catch
try { writer = SerializerProvider.CreateSerializerWriter(stream, descriptor); }
catch (ArgumentException ex) { /* ex.ParamName is the serializer key */ throw new InvalidOperationException($"Serializer version mismatch for {descriptor.DisplayName}.", ex); } Prevention
- Always source descriptors from SerializerProvider.InstalledSerializers
- Filter on IsLoadable before use
- Re-check descriptors after plug-in installs/upgrades
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- ArgumentNullException(nameof(writer))
- Cannot find the appropriate serializer.
- Cannot find the appropriate serializer.
- Cannot find the appropriate serializer.
- Cannot instantiate a serializer of the given type.
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/332df2d770c27ed0.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Serialization/SerializerProvider.cs:131
/// </summary>
/// <remarks>
/// With a SerializerProvider (which requires full trust to ctor) and a SerializerDescriptor (which requires
/// full trust to obtain) create a SerializerWriter
///
/// This method currently requires full trust to run.
/// </remarks>
public SerializerWriter CreateSerializerWriter(SerializerDescriptor serializerDescriptor, Stream stream)
{
SerializerWriter serializerWriter = null;
ArgumentNullException.ThrowIfNull(serializerDescriptor);
string serializerKey = $"{serializerDescriptor.DisplayName}/{serializerDescriptor.AssemblyName}/{serializerDescriptor.AssemblyVersion}/{serializerDescriptor.WinFXVersion}";
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);
}
View on GitHub (pinned to 81131a70a4)