Throw OpenXmlPackageException A shared part is referenced by multiple source parts with a different relationship type
See original GitHub issueDescribe the bug The OpenXML SDK will throw OpenXmlPackageException when open the special pptx file.
DocumentFormat.OpenXml.Packaging.OpenXmlPackageException: 'A shared part is referenced by multiple source parts with a different relationship type.'
And this pptx file can open well with Office PowerPoint.
Why the OpenXML SDK throw OpenXmlPackageException ?
Because the Relationship define the same part with a different relationship type. Such the test file in my repo, and the content in slide1.xml.rels
is:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" Target="../slideLayouts/slideLayout1.xml" />
<Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/video" Target="NULL" TargetMode="External" />
<Relationship Id="rId21" Type="http://schemas.microsoft.com/office/2006/relationships/recovered" Target="../media/media1.mp3" />
<Relationship Id="rId19" Type="http://schemas.microsoft.com/office/2007/relationships/media" Target="../media/media1.mp3" />
<Relationship Id="rId20" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="../media/image1.png" />
</Relationships>
And you can find the Type of media1.mp3
is http://schemas.microsoft.com/office/2006/relationships/recovered
and http://schemas.microsoft.com/office/2007/relationships/media
Screenshots
To Reproduce
My test code: https://github.com/lindexi/lindexi_gd/tree/d50ffc8321cbe33c50752557684581f1b1dc78f8/WhulaylurnurCearkolaifonerebairkur
- Download my code from: https://github.com/lindexi/lindexi_gd/tree/d50ffc8321cbe33c50752557684581f1b1dc78f8/WhulaylurnurCearkolaifonerebairkur
- Run the code
- See error
Observed behavior
Throw the OpenXmlPackageException.
DocumentFormat.OpenXml.Packaging.OpenXmlPackageException: 'A shared part is referenced by multiple source parts with a different relationship type.'
Call stack:
[Exception] DocumentFormat.OpenXml.dll!DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.LoadReferencedPartsAndRelationships(DocumentFormat.OpenXml.Packaging.OpenXmlPackage openXmlPackage, DocumentFormat.OpenXml.Packaging.OpenXmlPart sourcePart, DocumentFormat.OpenXml.Packaging.RelationshipCollection relationshipCollection, System.Collections.Generic.Dictionary<System.Uri, DocumentFormat.OpenXml.Packaging.OpenXmlPart> loadedParts) Unknown
[Exception] DocumentFormat.OpenXml.dll!DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.LoadReferencedPartsAndRelationships(DocumentFormat.OpenXml.Packaging.OpenXmlPackage openXmlPackage, DocumentFormat.OpenXml.Packaging.OpenXmlPart sourcePart, DocumentFormat.OpenXml.Packaging.RelationshipCollection relationshipCollection, System.Collections.Generic.Dictionary<System.Uri, DocumentFormat.OpenXml.Packaging.OpenXmlPart> loadedParts) Unknown
[Exception] DocumentFormat.OpenXml.dll!DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.LoadReferencedPartsAndRelationships(DocumentFormat.OpenXml.Packaging.OpenXmlPackage openXmlPackage, DocumentFormat.OpenXml.Packaging.OpenXmlPart sourcePart, DocumentFormat.OpenXml.Packaging.RelationshipCollection relationshipCollection, System.Collections.Generic.Dictionary<System.Uri, DocumentFormat.OpenXml.Packaging.OpenXmlPart> loadedParts) Unknown
[Exception] DocumentFormat.OpenXml.dll!DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Load(System.IO.Packaging.Package package) Unknown
[Exception] DocumentFormat.OpenXml.dll!DocumentFormat.OpenXml.Packaging.PresentationDocument.Open(string path, bool isEditable, DocumentFormat.OpenXml.Packaging.OpenSettings openSettings) Unknown
> [Exception] WhulaylurnurCearkolaifonerebairkur.dll!Program.<Main>$(string[] args) Line 3 C#
DocumentFormat.OpenXml.dll!DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Load(System.IO.Packaging.Package package) Unknown
DocumentFormat.OpenXml.dll!DocumentFormat.OpenXml.Packaging.PresentationDocument.Open(string path, bool isEditable, DocumentFormat.OpenXml.Packaging.OpenSettings openSettings) Unknown
WhulaylurnurCearkolaifonerebairkur.dll!Program.<Main>$(string[] args) Line 3 C#
Expected behavior
The OpenXML SDK can open the document. And I think we should handle the http://schemas.microsoft.com/office/2006/relationships/recovered
type.
Desktop (please complete the following information):
- OS: Windows 10 21H2 19044
- Office version None.
- .NET Target: dotnet 6.0.9
- DocumentFormat.OpenXml Version: 2.18.0
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
@lindexi thanks for confirming and bringing this to our attention.
@lindexi I’ve added PR #1207 that should fix the loading issue. Please feel free to clone my branch and test if you’d like.