none
Could not load file or assembly Microsoft.Office.Interop.Excel RRS feed

  • Question

  • My asp.net application is throwing this exception:

    Could not load file or assembly 'Microsoft.Office.Interop.Excel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.

    I've installed:

    Microsoft Office Access Database Engine 2007

    Microsoft Office 2003 Web Components

     

    In the code, I'm importing Microsoft.Office.Interop and using classes in the Excel namespace. It works on one of my other test servers but not this one. I don't have office installed on either servers, but it works on one but not the other.

    I've checked C:\windows\assembly for any differences, but I don't see anything.
    I've searched for excel.dll, office, interop on the hard drives but nothing obvious comes up.

    Wednesday, February 10, 2010 9:24 PM

Answers

  • hey Btabios,

    the interop libraries are not part of .NET framework itself, rather part of visual studio.  you can the copy the Interop library from "Program Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office12" and paste on the server.  please refer to the following topic to understand how assemblies are loaded.  http://msdn.microsoft.com/en-us/library/yx7xezcf.aspx

    i have added the interop assembly in GAC using gacutil provided with .NET Framework 2.0 and it exists peacefully with interop library 11.

    regards,


    kashif
    • Marked as answer by BTabios Thursday, February 18, 2010 4:41 PM
    Thursday, February 11, 2010 3:19 PM
  • Hi Kashif,

    Here is what I've tried.

    1. Create a project that installs Microsoft.Office.Interop.Excel.dll 12.0.0.0 into the GAC. It also automatically installed office.dll and Microsoft.Vbe.Interop.dll into the GAC
    2. Verified that the files existed in C:\Windows\Assembly folder.
    3. Restarted the server.

    I'm still getting the error as noted above. I'm thinking of just buying office as Yasser suggested. Does anyone know what version I need to buy? Will Office 2007 include the proper libraries?
    • Marked as answer by BTabios Friday, February 26, 2010 5:04 PM
    Thursday, February 18, 2010 4:05 PM
  • I'm going to mark Kashif's reply as the answer to my problem.

    After installing Microsoft.Office.Interop.Excel.dll version 12.0.0.0 into the GAC and restarting the server. ASP.NET seems to find the proper assembly correctly. I am no longer received the above exception.

    The new exception I am getting is:
    Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154.

    After initial research and some unsuccessful troubleshooting I've decied to go ahead and purchase Excel for our server. This should install the excel libraries correctly and I should be able to program against the Excel classes without error.
    • Marked as answer by BTabios Friday, February 26, 2010 5:04 PM
    Thursday, February 18, 2010 4:44 PM

All replies

  • You must instal excell on the machine which that asp run on it.
    Please help us improve this community forum for visitors by marking the replies as answers if they help and unmarking them if they provide no help.
    Thanks.
    Wednesday, February 10, 2010 9:43 PM
  • How come I don't get the error on my other server, even though office is not installed on it?
    Wednesday, February 10, 2010 9:50 PM
  • No way, you should install Office on it too if you have to use office.
    Also you can use third-party softwares, please see this same problem: Is it possible to update an xlsx from c# executable without having excel.exe installed on the machine?
    Please help us improve this community forum for visitors by marking the replies as answers if they help and unmarking them if they provide no help.
    Thanks.
    Wednesday, February 10, 2010 10:03 PM
  • Can anyone tell me which version of office I need to install in order to use the Office.Interop.Excel Version 12.0.0.0 library?
    • Edited by BTabios Thursday, February 11, 2010 2:42 PM
    Thursday, February 11, 2010 2:29 PM
  • Yes of course, you can use Excel Primary Interop Assemblies but you can't open Excel files if it is requiered?
    Please help us improve this community forum for visitors by marking the replies as answers if they help and unmarking them if they provide no help.
    Thanks.
    Thursday, February 11, 2010 2:42 PM
  • hey Btabios,

    the interop libraries are not part of .NET framework itself, rather part of visual studio.  you can the copy the Interop library from "Program Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office12" and paste on the server.  please refer to the following topic to understand how assemblies are loaded.  http://msdn.microsoft.com/en-us/library/yx7xezcf.aspx

    i have added the interop assembly in GAC using gacutil provided with .NET Framework 2.0 and it exists peacefully with interop library 11.

    regards,


    kashif
    • Marked as answer by BTabios Thursday, February 18, 2010 4:41 PM
    Thursday, February 11, 2010 3:19 PM
  • Hi BTabios,

    Did any of the suggestions work?  Do let us know if you are good to go and if you would share what it took to get there, it would be great for the community.

    regards,
    kashif
    Tuesday, February 16, 2010 11:52 AM
  • Hi BTabios,

    I'm writing to check the issue status, please feel free to let us know if you have any concern.


    Sincerely,
    Eric
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Thursday, February 18, 2010 1:45 AM
  • Hi Kashif,

    Here is what I've tried.

    1. Create a project that installs Microsoft.Office.Interop.Excel.dll 12.0.0.0 into the GAC. It also automatically installed office.dll and Microsoft.Vbe.Interop.dll into the GAC
    2. Verified that the files existed in C:\Windows\Assembly folder.
    3. Restarted the server.

    I'm still getting the error as noted above. I'm thinking of just buying office as Yasser suggested. Does anyone know what version I need to buy? Will Office 2007 include the proper libraries?
    • Marked as answer by BTabios Friday, February 26, 2010 5:04 PM
    Thursday, February 18, 2010 4:05 PM
  • I'm going to mark Kashif's reply as the answer to my problem.

    After installing Microsoft.Office.Interop.Excel.dll version 12.0.0.0 into the GAC and restarting the server. ASP.NET seems to find the proper assembly correctly. I am no longer received the above exception.

    The new exception I am getting is:
    Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154.

    After initial research and some unsuccessful troubleshooting I've decied to go ahead and purchase Excel for our server. This should install the excel libraries correctly and I should be able to program against the Excel classes without error.
    • Marked as answer by BTabios Friday, February 26, 2010 5:04 PM
    Thursday, February 18, 2010 4:44 PM
  • Hi there.

    Just in case, Ive had the same issue that you had. I have a small .Net app in a server that actually doesn´t have office just the OS, but the stations that use this app have office, so that in that machines I installed the PIA components which y pàrt of the office install  if you don´t have such components U could obtain from MSDN easily. I hope it helps, it worked for me.

    Wednesday, June 16, 2010 1:20 AM
  • I could solve this by deploying Microsoft Visual Studio 10.0\Visual Studio Tools for Office\PIA\Office14\Microsoft.Office.Interop.Excel.dll to GAC. 
    • Proposed as answer by Emanon Labs Wednesday, August 28, 2013 4:13 PM
    Wednesday, August 28, 2013 4:12 PM