I am trying to use ClosedXML to produce excel documents within an application however when ever I try to run it I receive a could not load file or assembly server error.
Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
I have seen several solution to this that include changing the 'Copy Local' value for the .dll in its properties and adding the assembly directly to the web.config.
I'm using Visual Studios 2010 and the dll properties does not include a 'copy local' entry. Then when I enter the following assembly in the web config I still get the same server error message. I got the assembly from the error message provided.
<add assembly="ClosedXML, Version=0.76.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b"/>
After going crazy searching for answers and finally posting a question, I came across the simplest answer and once I referenced the additional .dll everything worked correctly.
To use ClosedXML you must reference the DocumentFormat.OpenXml.dll:
DocumentFormat.OpenXml.dll for NET 4.0+