Home » excel » asp.net – Could not load file or assembly 'Microsoft.Office.Interop.Excel, Version=14.0.0.0

asp.net – Could not load file or assembly 'Microsoft.Office.Interop.Excel, Version=14.0.0.0

Posted by: admin April 23, 2020 Leave a comment

Questions:

I have web-site that uses MS Excel files read/write.

I added related dll’s to Bin folder of the site, and it works perfect on my local host (I think bacause I have installed MS Excel 2010 on my pc)

But when I uploaded it to remote pc and run the site, it throws an error:

Could not load file or assembly ‘Microsoft.Office.Interop.Excel,
Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ or
one of its dependencies. The located assembly’s manifest definition
does not match the assembly reference. (Exception from HRESULT:
0x80131040)

files in Bin folder are:

Microsoft.Vbe.Interop.dll 
office.dll 
Microsoft.Office.Interop.Excel.dll 
Microsoft.Office.Interop.Excel.xml 
office.xml 

I’ve installed on remote pc “Microsoft Office 2010: Primary Interop Assemblies Redistributable”,
http://www.microsoft.com/en-us/download/details.aspx?id=3508

But same error ocurrs.

How to resolve this issue?

Thanks.

How to&Answers:

One way – Install MS Office (MS Excel)

Answer:

I know that this thread is a little bit old but I had the same error and I solved it (it works in my project).

In my web.config file I had assemblies added:

<add assembly="office, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"/> and many other office assemblies.

The thing I have done is that I have removed all the assemblies from web.config file and had added dlls as a reference – Microsoft.Office.Interop.Excel.dll in this case.

I am not an expert and I just thinking loudly that web.config file is trying to pull dll. file from C:\Windows\assembly\ and if there if it could not be foud, returns error.

You don’t have to install office or other unneccessary stuff on you server.

Hope this help someone.

Answer:

you no need to install MS Office- 2010,
Add Reference -> COM-> “Microsoft office 12.0 Object Libaray”

its works for me.

Answer:

Correct procedure to use Excel in C# Projects is:

  1. Add reference to Excel Interop Library(Assembly)
  2. Add Excel in using section
  3. Now use it in your coding.


The first step will work if you have Office(Excel) Installed in your PC. If not then install. Then add reference to Microsoft.Office.Interop.Excel of the version you need.

a. If list doesn’t shows the desire version then you may have another vision of Office with Excel installed. By The Way, you can use any.

b. If you don’t find anything like Microsoft.Office.Interop THEN may be office not installed OR you have Office 2013 or later. For higher version you can add assembly by going into COM tab of add-reference windows and add Microsoft Excel {version-no} Object Library. This will add the same.

c. If you already have Microsoft.Office.Interop... in References with yellow-triangle-mark THEN remove it first.



After that second step will totally work: using Excel=Microsoft.Office.Interop.Excel;



And finally as a third step you can create Excel object by Excel.Application xlApp = new Excel.Application();.