dotnet/wpf · error · System.Xml.XmlException

SR.MultipleRelationshipTransformsFound

Error message

SR.MultipleRelationshipTransformsFound

What it means

The manifest contained more than one Relationship transform for the same Reference. The OPC spec permits at most a single Relationship Transform per Reference, so when a second one is detected the library throws MultipleRelationshipTransformsFound.

Solutions

  1. Edit the signature so only one Relationship Transform appears per Reference, and re-sign
  2. Configure the signing tool to emit a single Relationship Transform covering all needed relationship types
  3. Re-sign the package entirely with PackageDigitalSignatureManager instead of the offending tool
  4. Regenerate the package signature after fixing the manifest template

Example fix

// before
<Transforms>
  <Transform Algorithm="http://schemas.openxmlformats.org/package/2006/RelationshipTransform"/>
  <Transform Algorithm="http://schemas.openxmlformats.org/package/2006/RelationshipTransform"/>
</Transforms>
// after
<Transforms>
  <Transform Algorithm="http://schemas.openxmlformats.org/package/2006/RelationshipTransform"/>
</Transforms>
Defensive patterns

Strategy: validation

Validate before calling

const string relNs = "http://schemas.openxmlformats.org/package/2006/RelationshipTransform";
int relCount = doc.Descendants(ds + "Reference")
    .Count(r => r.Elements(ds + "Transforms").Descendants(ds + "Transform")
        .Count(t => (string)t.Attribute("Algorithm") == relNs) > 1);
if (relCount > 0) throw new InvalidDataException("Duplicate Relationship Transform in a Reference");

Try / catch

try
{
    sigManager.VerifySignatures(true);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("Relationship"))
{
    // duplicate Relationship transform: re-sign with a compliant tool
}

Prevention

When it happens

Trigger: Verify on a signature whose Reference lists two <Transform Algorithm=".../RelationshipTransform"> entries (or one with multiple relationship selections producing a second transform) for the same part.

Common situations: Signing tools that append a Relationship transform for each relationship type instead of consolidating into one; templates copied and merged incorrectly; automated pipelines adding the transform repeatedly.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/07e1f1ec3b5d4f13. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlSignatureManifest.cs:363

                    // what type of transform?
                    if (string.Equals(transformName, XTable.Get(XTable.ID.RelationshipsTransformName), StringComparison.Ordinal))
                    {
                        if (!relationshipTransformFound)
                        {
                            // relationship transform
                            ParseRelationshipsTransform(reader, partUri, ref relationshipSelectors);

                            if (transforms == null)
                                transforms = new List<String>();

                            transforms.Add(transformName);

                            relationshipTransformFound = true;
                            transformsCountWhenRelationshipTransformFound = transforms.Count;
                            continue;   // success
                        }
                        else
                            throw new XmlException(SR.MultipleRelationshipTransformsFound);
                    }                    
                    else
                    {
                        // non-Relationship transform should have no children
                        if (reader.IsEmptyElement)
                        {
                            if (transforms == null)
                                transforms = new List<String>();

                            if (XmlDigitalSignatureProcessor.IsValidXmlCanonicalizationTransform(transformName))
                            {
                                transforms.Add(transformName);  // return it
                                continue;   // success
                            }
                            else
                                throw new InvalidOperationException(SR.UnsupportedTransformAlgorithm);
                        }
                    }

View on GitHub (pinned to 81131a70a4)