Skip to content

TypeLoadException Due to Version Mismatch in DocumentFormat.OpenXml #54

Description

@vaceslav

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions