dotnet/wpf · error · XpsPackagingException

ReachPackaging_PackageUriNull

Error message

ReachPackaging_PackageUriNull

What it means

GetFixedDocumentSequence throws this XpsPackagingException when the XpsDocument's Uri is null — typically because the document was constructed from a stream without a package URI. Resolving the root starting part via a pack URI is impossible without a Uri, so the read is rejected.

Solutions

  1. Construct the XpsDocument with the Uri overload so the package URI is known
  2. Do not call GetFixedDocumentSequence on a package created from a bare Stream without a URI
  3. Supply the package URI via the XpsDocument constructor before reading
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsDocument.cs:594 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/ea78e3731bb62659. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsDocument.cs:594

        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 ParserContext
            {
                BaseUri = PackUriHelper.Create(Uri, CurrentXpsManager.StartingPart.Uri)
            };

            Uri packageUri = PackUriHelper.GetPackageUri(parserContext.BaseUri);

View on GitHub (pinned to 81131a70a4)