Using IronWord with DocumentFormat.OpenXml
Using both packages together can lead to errors, unexpected output, or runtime conflicts within IronWord.
Root Cause
The conflict arises due to internal type and dependency mismatches between IronWord and newer versions of DocumentFormat.OpenXml. These mismatches can cause:
-
Document corruption
-
Incorrect formatting
-
Exceptions at runtime (e.g.,
System.InvalidOperationException,NullReferenceException, etc.)
Recommended Solution
If your project requires the use of both packages:
✅ Use DocumentFormat.OpenXml version 2.8.1 only.
This is the only known version compatible with IronWord without causing stability or functionality issues.
You can install this specific version using NuGet:
Install-Package DocumentFormat.OpenXml -Version 2.8.1
Alternatively:
❌ Do not use DocumentFormat.OpenXml if it is not essential to your workflow.
Stick with IronWord exclusively to ensure optimal performance and output reliability.
Summary
| Scenario | Recommendation |
|---|---|
| Need to use both IronWord and OpenXml | Use DocumentFormat.OpenXml v2.8.1 only |
| Using only IronWord | No issues expected |
| Using a newer version of DocumentFormat.OpenXml | Not supported — may break IronWord |