Skip to content

TypeLoadException Due to Version Mismatch in DocumentFormat.OpenXml #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vaceslav opened this issue Feb 4, 2025 · 0 comments
Open

Comments

@vaceslav
Copy link

vaceslav commented Feb 4, 2025

Description

I am using the NuGet package DocumentFormat.OpenXml version 3.2.0 in my project. However, when I attempt to read my template file, I encounter the following exception:

System.TypeLoadException: Could not load type 'DocumentFormat.OpenXml.OpenXmlElementList' from assembly 'OpenXMLTemplates, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' due to value type mismatch.
   at OpenXMLTemplates.OpenXmlExtensions.DescendantsBreadthFirst[T](OpenXmlElement element)+MoveNext()
   at OpenXMLTemplates.OpenXmlExtensions.ContentControls(WordprocessingDocument doc)+MoveNext()
   at OpenXMLTemplates.Documents.TemplateDocument..ctor(WordprocessingDocument wpd)
   at OpenXMLTemplates.Documents.TemplateDocument..ctor(String filePath)
   ......

Cause

This issue occurs due to a version mismatch between DocumentFormat.OpenXml dependencies. The project is currently using DocumentFormat.OpenXml version 3.2.0, but it appears that OpenXMLTemplates is built against an older version (2.9.1), leading to compatibility issues.

Proposed Solution

To resolve this issue, OpenXMLTemplates should be updated to use DocumentFormat.OpenXml version 3.2.0 instead of 2.9.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant