I'm keep getting this error is VS2013
Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neut
ral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
In my web.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="hjkom_med_web_udvConnectionString" connectionString="Data Source=M95;Initial Catalog=hjkom-med_web;Persist Security Info=True;User ID=HJkom-MED_web;Password=bvkeB7hh" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
**<add assembly="DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>**
</assemblies></compilation>
</system.web>
</configuration>
I have tried to insert windowsbase and a lot of other things.
I have search and search for a solution, do any body know how to fix it?
Check in Packages.config files, in all your projects with in that solution.It's should be same in all projects inside a solution. for reference purpose
At the time of writing this answer, there are 3 versions of Open XML SDK:
You most probably have referenced in your project DLL version 2.5 which was installed on your machine.
To get required v2.0 assembly, I suggest you to use NuGet I provided above.
Had the same problem recently.
I have ClosedXML referenced in a library and when I use the library in a console application I get missing reference error.
This is because the DocumentFormat.Excel, ExcelNumberFormat and FastMember.Signed are not copied into the output folder of my console application.
2 solutions :
1) install the closedXML nuget package and all its dependencies in the client (console application project in this case).
2) To have the dll copied you have to reference them in the library. Add the following function to the library and call it from the static constructor:
You can look this example.
http://www.aspsnippets.com/Articles/Solution-ASPNet-GridView-Export-to-Excel-The-file-you-are-trying-to-open-is-in-a-different-format-than-specified-by-the-file-extension.aspx
I download the example and i imported the
dlls (realted dlls is allready in project. And i used them). After that my error is gone. You can try.. I dont know why. But the importent is my project is working right now..
I had this problem because I had a new version of the .dll installed on my computer running on localhost and my server was running an old version of the same .dll
I just updated it and everything works well after that.
In your case, install the DocumentFormat.OpenXml version 2.5 available in this microsoft link