question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Throw OpenXmlPackageException A shared part is referenced by multiple source parts with a different relationship type

See original GitHub issue

Describe 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

  1. Download my code from: https://github.com/lindexi/lindexi_gd/tree/d50ffc8321cbe33c50752557684581f1b1dc78f8/WhulaylurnurCearkolaifonerebairkur
  2. Run the code
  3. 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:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tomjebocommented, Sep 16, 2022

@lindexi thanks for confirming and bringing this to our attention.

1reaction
tomjebocommented, Sep 16, 2022

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

OpenXml Excel: throw error in any word after mail address
Here is the entire work-around source code, just in case one of these links goes away in the future: void Main(string[] args) {...
Read more >
Part to Document Relationships (Products and Libraries)
The relationships between a part and a document, two parts, or two documents vary depending upon how the two objects are linked.
Read more >
DocumentFormat.OpenXml 2.20.0
Populating content in Word files from an XML data source. - Splitting up (shredding) a Word or PowerPoint file into multiple files, and...
Read more >
Part to Document Relationships (Projects)
Part to document relationships apply to projects only; parts are not used within programs. ... There are two types of links that can...
Read more >
Untitled
Gets the source relationship type for a media reference. ... to A shared part is referenced by multiple source parts with a different...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found