IronWord with DocumentFormat.OpenXml
Running IronWord alongside DocumentFormat.OpenXml can produce corrupted documents, incorrect formatting, or runtime errors when the two packages share a project.
System.InvalidOperationException
NullReferenceException
The trouble comes from internal type and dependency mismatches between IronWord and newer releases of DocumentFormat.OpenXml. When those versions disagree, you see document corruption, broken formatting, or exceptions thrown at runtime.
Solution
Option 1: Pin DocumentFormat.OpenXml to 2.8.1
If your project genuinely needs both packages, lock DocumentFormat.OpenXml to version 2.8.1. It is the only version known to coexist with IronWord without stability or output problems.
Install-Package DocumentFormat.OpenXml -Version 2.8.1
Install-Package DocumentFormat.OpenXml -Version 2.8.1
Option 2: Drop DocumentFormat.OpenXml
When the package is not essential to your workflow, remove it and rely on IronWord alone. Using IronWord on its own avoids the conflict entirely and keeps output reliable.

