dotnet/wpf · error · XpsSerializationException
SR.ReachSerialization_MustHaveSerializationManager
Error message
SR.ReachSerialization_MustHaveSerializationManager
What it means
ReachSerializer.SerializeObject refuses to serialize an object when its SerializationManager property is null. The serializer needs the manager to discover object data, write parts, and resolve packaging; without it serialization cannot proceed, so a synchronous XpsSerializationException is thrown immediately after the null check on the object itself.
Solutions
- Create and pass an XpsSerializationManager (via XpsPackagingPolicy) when constructing the serializer instead of null
- Drive serialization through XpsDocument/XpsSerializationManager public APIs rather than instantiating ReachSerializer subclasses directly
- Assert SerializationManager is assigned before calling SerializeObject
Example fix
// before var serializer = new ReachPageSerializer(null); serializer.SerializeObject(page); // after var manager = new XpsSerializationManager(new XpsPackagingPolicy(package), false); var serializer = new ReachPageSerializer(manager); serializer.SerializeObject(page);
Defensive patterns
Strategy: validation
Validate before calling
if (serializer.SerializationManager == null) throw new InvalidOperationException("Serializer not initialized with an XpsSerializationManager"); Try / catch
try { serializer.SerializeObject(obj); }
catch (XpsSerializationException ex) when (ex.Message.Contains("SerializationManager")) { /* re-init manager and retry */ } Prevention
- Always construct serializers with a valid manager
- Prefer XpsDocument/XpsSerializationManager public APIs over internal serializer classes
- Initialize manager and serializer together in one factory method
When it happens
Trigger: Calling SerializeObject on a ReachSerializer instance (e.g. a ReachPageSerializer or a serializer obtained directly) that was never associated with an IXpsSerializationManager, or using one after its manager reference was cleared.
Common situations: Manually instantiating Reach*Serializer classes instead of driving serialization through XpsSerializationManager/XpsDocument; custom walker code that constructs serializers with a null manager.
Understand the failure class
Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.
Related errors
- SR.ReachSerialization_MustHaveSerializationManager
- 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/3e1466ab2ae558fb.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachSerializer.cs:73
/// <summary>
/// The main method that is called to serialize the object of
/// that given type.
/// </summary>
/// <param name="serializedObject">
/// Instance of object to be serialized.
/// </param>
public
virtual
void
SerializeObject(
Object serializedObject
)
{
ArgumentNullException.ThrowIfNull(serializedObject);
if (SerializationManager == null)
{
throw new XpsSerializationException(SR.ReachSerialization_MustHaveSerializationManager);
}
//
// At this stage discover the graph of properties of the object that
// need to be serialized
//
SerializableObjectContext serializableObjectContext = DiscoverObjectData(serializedObject,
null);
if(serializableObjectContext!=null)
{
//
// Push the object at hand on the context stack
//
SerializationManager.GraphContextStack.Push(serializableObjectContext);
//
// At this stage we should start streaming the markup representing the
// object graph to the corresponding destinationView on GitHub (pinned to 81131a70a4)