dotnet/wpf · error · XpsPackagingException
ReachPackaging_NotOpenForReading
Error message
ReachPackaging_NotOpenForReading
What it means
GetFixedDocumentSequence throws this XpsPackagingException when the XpsDocument was not opened for reading (IsReader is false — e.g. opened write-only or for creation). Reading the root fixed document sequence requires read access to the package.
Solutions
- Open the XpsDocument with access mode that allows reading (or FileAccess.Read / ReadWrite) instead of write-only
- Open a new XpsDocument instance with read access to consume the content
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsDocument.cs:589 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/88362856c514f14e.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsDocument.cs:589
/// <returns>A XpsPartBase representing the root.</returns>
/// <remarks>Method will be internal until reading/de-serialization is implemented.</remarks>
/// <exception cref="SR.ReachPackaging_PackageUriNull">XpsPakage Uri is null. Use XpsDocument constructor that takes Uri parameter.</exception>
/// <exception cref="SR.ReachPackaging_InvalidStartingPart">Package starting part is not a valid root.</exception>
/// <exception cref="SR.ReachPackaging_NotAFixedDocumentSequence">Part Uri does not corresepond to a Fixed Document Sequence.</exception>
public
FixedDocumentSequence
GetFixedDocumentSequence(
)
{
CheckDisposed();
if( CurrentXpsManager == null )
{
throw new InvalidOperationException(SR.ReachPackaging_DocumentWasClosed);
}
if (!IsReader)
{
throw new XpsPackagingException(SR.ReachPackaging_NotOpenForReading);
}
if (null == Uri)
{
throw new XpsPackagingException(SR.ReachPackaging_PackageUriNull);
}
if (CurrentXpsManager.StartingPart == null)
{
return null;
}
ContentType startPartType = CurrentXpsManager.StartingPart.ValidatedContentType();
if (!startPartType.AreTypeAndSubTypeEqual(XpsS0Markup.DocumentSequenceContentType))
{
throw new XpsPackagingException(SR.ReachPackaging_InvalidStartingPart);
}
ParserContext parserContext = new ParserContextView on GitHub (pinned to 81131a70a4)