Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load file or assembly 'DocumentFormat.OpenXml

I'm keep getting this error is VS2013

Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, 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?

like image 228
SanderDk Avatar asked Aug 14 '14 11:08

SanderDk


People also ask

What is DocumentFormat OpenXml?

The Open XML SDK provides tools for working with Office Word, Excel, and PowerPoint documents. It supports scenarios such as: - High-performance generation of word-processing documents, spreadsheets, and presentations. - Populating content in Word files from an XML data source.

How install DocumentFormat OpenXml?

Go to your Solution Explorer > right click on references and then click Manage NuGet Packages . Then search in tab "Online" for DocumentFormat. OpenXml and install it.

Can not load file or assembly?

Http 5.2. 0.0? In summary if you get the "Could not load file or assembly error", this means that either your projects or their references were built with a reference to a specific version of an assembly which is missing from your bin directory or GAC.


2 Answers

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

like image 193
Lucas Avatar answered Sep 30 '22 11:09

Lucas


At the time of writing this answer, there are 3 versions of Open XML SDK:

  • Open XML SDK 1.0 (NuGet link)
  • Open XML SDK 2.0 (NuGet link)
  • Open XML SDK 2.5 (NuGet link)

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.

like image 31
HRKoder Avatar answered Sep 30 '22 12:09

HRKoder