I am trying to process a word document. For that, I installed the DocumentFormat.OpenXml NuGet package. It installed following dependencies:
- DocumentFormat.OpenXml
- System.IO.Packaging (4.5.0)
- System.Runtime.Serialization
As soon as it hit the code where I am processing the word document. It throws this error "Could not load file or assembly 'System.IO.Packaging, Version=4.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified."
I have tried the following things so far:
- Try to manually add a reference of System.IO.Packaging to CSPROJ file but that didn't work and I got the same error.
<ItemGroup>
<PackageReference Include="DocumentFormat.OpenXml" Version="2.9.1" />
<PackageReference Include="System.IO.Packaging" Version="4.5.0" />
<PackageReference Include="System.Data.Common" Version="4.3.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.6.1" />
</ItemGroup>
- I tried to add "WindowsBase" nuget package but it displayed a conflict:
The type 'Package' exists in both 'System.IO.Packaging, Version=4.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
The error is complaining about version 4.0.3.0 but nuget added version 4.5.0 of System.IO.Packaging DLL. How can I fix that?