dotnet/wpf · error · XpsSerializationException
SR.ReachSerialization_NoFixedPageWriter
Error message
SR.ReachSerialization_NoFixedPageWriter
What it means
AcquireResourceStreamForXpsFont requires an open fixed-page writer to attach the new font part to. If the font is not cached and _currentFixedPageXmlWriter is null (no page is open), XpsSerializationException(SR.ReachSerialization_NoFixedPageWriter) is thrown because a font part cannot be created without page context.
Solutions
- Only call AcquireResourceStreamForXpsFont while a FixedPage is open (between AcquireXmlWriterForFixedPage and ReleaseXmlWriterForFixedPage).
- Acquire the page writer first in your serialization order.
- If the policy was invalidated by a cancel, start a new print job rather than reusing it.
Example fix
// before var s = policy.AcquireResourceStreamForXpsFont(id); // throws: no page open // after policy.AcquireXmlWriterForFixedPage(); var s = policy.AcquireResourceStreamForXpsFont(id); ... write font ... policy.ReleaseResourceStreamForXpsFont(id); policy.ReleaseXmlWriterForFixedPage();
Defensive patterns
Strategy: validation
Validate before calling
if (!pageOpen) throw new InvalidOperationException("AcquireXmlWriterForFixedPage must be called before AcquireResourceStreamForXpsFont"); Type guard
static bool CanAcquireFont(bool pageOpen) => pageOpen;
Try / catch
try { var s = policy.AcquireResourceStreamForXpsFont(id); }
catch (XpsSerializationException ex) { log("Font stream requested with no open FixedPage", ex); } Prevention
- Acquire fonts strictly inside the page scope
- Verify lifecycle order before resource acquisition
- Reuse the same resourceId to hit the font cache
- Do not use a policy after cancellation
When it happens
Trigger: Requesting a font resource stream (new resourceId not in _fontsCache) before AcquireXmlWriterForFixedPage or after ReleaseXmlWriterForFixedPage; acquiring fonts outside page scope.
Common situations: Custom serialization acquiring font streams in the wrong phase; continuing to fetch fonts after a page was released; reusing the policy after invalidation reset the page writer.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Count must be 1 when CommitPolicies is set to…
- CurrentFixedPageWriter uninitialized
- FixedPageReader
- No font service is registered with resource policy.
- Serialization of this type of object is not supported.
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/411264f79413b163.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/XpsOMPackagingPolicy.cs:482
IXpsOMFontResourceCollection fontCollection = _xpsPartResources.GetFontResources();
fontCollection.Append(fontResource);
XpsResourceStream fontResourceStream = new XpsResourceStream(fontStreamWrapper, uri);
resourceStreamCacheItem.XpsResourceStream = fontResourceStream;
_fontsCache[resourceId] = resourceStreamCacheItem;
resourceStream = fontResourceStream;
}
catch (COMException)
{
Invalidate();
throw new PrintingCanceledException();
}
}
else
{
throw new XpsSerializationException(SR.ReachSerialization_NoFixedPageWriter);
}
}
else
{
resourceStream = resourceStreamCacheItem.XpsResourceStream;
resourceStreamCacheItem.IncRef();
}
return resourceStream;
}
/// <summary>
/// This is never called during printing, but we must implement it from
/// abstract class BasePackagingPolicy
/// </summary>
public
override
voidView on GitHub (pinned to 81131a70a4)