dotnet/wpf · error · XmlException

SR.InvalidUriAttribute

Error message

SR.InvalidUriAttribute

What it means

ValidateReferences throws this XmlException when a Reference's Uri attribute is not a fragment identifier — per the OPC spec the Uri must be relative using '#...' form; absolute URIs are rejected as invalid.

Solutions

  1. Ensure each Reference Uri attribute uses only a fragment identifier (starts with '#') per the OPC spec
  2. Re-generate the signature so references are relative fragments, not absolute URIs
  3. Treat the XmlException as a verification failure for non-conformant signatures
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlDigitalSignatureProcessor.cs:1198 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/7373376836487369. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlDigitalSignatureProcessor.cs:1198

                        //If there are more than one package specific tags
                        if (packageReferenceFound)
                            throw new XmlException(SR.MoreThanOnePackageSpecificReference);
                        else
                            packageReferenceFound = true;
                    }

                    currentTransformChain = currentReference.TransformChain;

                    for(int j=0; j<currentTransformChain.Count; j++)
                    {
                        //As per the OPC spec, only two transforms are supported for the reference tags
                        if (!IsValidXmlCanonicalizationTransform(currentTransformChain[j].Algorithm))
                            throw new XmlException(SR.UnsupportedTransformAlgorithm);
                    }
                }
                else
                    throw new XmlException(SR.InvalidUriAttribute);
            }

            // If there are zero reference tags or if there wasn't any package specific reference tag            
            if (allowPackageSpecificReferences && !packageReferenceFound)
                throw new XmlException(SR.PackageSignatureReferenceTagRequired);
        }


        //------------------------------------------------------
        //
        //  Private Members
        //
        //------------------------------------------------------
        private PackagePart _signaturePart;
        private X509Certificate2                    _certificate;       // non-null if it's embedded
        private bool                                _lookForEmbeddedCert;
        private PackageDigitalSignatureManager      _manager;
        private PackageDigitalSignature             _signature;         // parsed from part or newly created

View on GitHub (pinned to 81131a70a4)