I have developped an asp.net application using microsoft office interop excel on my local machine, everything worked well, an excel file was build.
When I deploy the application on my server and run it, I am getting the following exception :
Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046}
failed due to the following error: 80040154 Class not registered
(Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
I have done some research on forums, I know that it's probably because excel is missing on the server, however I am not able to find an appropriate solution, knowing that install excel on the server is not really possible. And also knowing that I would like to keep interop as my library.
Does anyone have a solution?
First, what ever you are trying to do, try to do it without using Excel (or any Office) interop in ASP.NET. Microsoft strongly discourages it, as it might not work as you expect.
There are plenty possibilities to do this without the 'client application' Excel, for example EPPlus.
Second, the problem with your code is the lack of Office installed or the wrong version of Office (also consider 32- or 64-bit platform versions).
Related
I have developed a windows service that would read doc / docx files and replace values based on database records and convert the replaced document as PDF.
Used Microsoft Office Interop DLL for the conversion. The service is hosted in two different machines ( Win Server 2008 R2 Enterprise - 64 Bit ). I had to
set the Identity as Interactive User in DCOM settings to solve the exception :
Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046}failed due to the following error: 8000401a.
Initially I couldn't not find the DCOM entry for Microsoft Windows Document. So I had to change some settings in the registry following this link. This got me working in one system ( the service working fine). However, in another system, the service threw an exception Attempted to read or write protected memory. This is often an indication that other memory is corrupt on WorkDocument.ClearFormatting() code.
To overcome that I had changed the build properties form "Any CPU" to "x86". The service worked fine for some times but it just started to throw the exception (Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 8000401a) again. I could not figure out when the service starts throwing this exception. If I restart the service it works normal but not for too long.
I know using MS interop is not recommended for services. But i came to know about this issue only after the complete development of the service as I had no problems running the program as windows application on my system for testing purposes.
Tried with google and have even solved the issue but the solution seems to be a temporary one for one server and the other seems to work fine. Kindly guide me to overcome the situation.
Thanks
I'm trying to run my application on a server which does not and will not have Office installed on it.
using EXCEL = Microsoft.Office.Interop.Excel;
...
EXCEL.Application app = new EXCEL.Application();//Exception thrown here
The code is working fine on my own system, but on the server it gives the following exception:
Unhandled Exception: System.Runtime.InteropServices.COMException:
Retrieving the COM class factory for component with CLSID {...} failed
due to the following error: 80040154 Class not registered
(Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
both systems are 32bits, and I've copied the excel Interop dll next to application's exe. I've also installed O2010PIA.
any lead?
The Office Interop assemblies are runtime-callable wrappers (RCW) that allow you to interoperate with a copy of Office that's installed on the system via the COM API that it exposes.
The error message indicates that Excel isn't installed, exactly what I'd expect. You can't use the Interop assemblies on a machine without Office.
I'm trying to run my application on a server which does not and will
not have Office installed on it.
As Joe said, you'll need to install Excel for Interop to work. If you're dead-set against that, consider third-party alternatives. In general, Microsoft did not recommend installing Office on your server and using it with Interop - that being said, it will work (at least most of the time).
I have a web application that create an access database. When I want to create this database, I add Microsoft.Office.Interpob.access.dao.dll from COM references.
This application work in my pc very well. But when I put this application in the customer server I get this error:
Retrieving the COM class factory for component with CLSID {CD7791B9-43FD-42C5-AE42-8DD2811F0419} failed due to the following error: 80040154
Note that the Microsoft Office Access is not install in customer server. Must I Install this program on this server or can I add some dll to resolve this problem or I have to do anything else?
Thanks.
Check out these links, they might help:
social.msdn.microsoft.com - "Error 80040154 retreiving COM Class factory"
asp.net - "Retrieving COM class factory failed due to the following error: 80040154"
software602.com - "KB987: Error code 80040154. Class not registered"
I know this is a little late for the the original poster, but hopefully this will be useful to others. The correct answer is:
No, you don't need to install Microsoft Office Access on the server.
But, you do need to install the Microsoft Office Access Runtime on the server. From my limited experience it doesn't seem to matter which office runtime - I had the 2013 runtime installed locally but when I installed the runtime on my server it was fine with the 2016 runtime (so both installed the required COM object). In my case I was installing the x64 version.
The Microsoft Office Access Runtime is free from Microsoft.
The Microsoft Access 2013 Runtime can be downloaded from: https://www.microsoft.com/en-gb/download/details.aspx?id=39358
The Microsoft Access 2016 Runtime can be downloaded from https://www.microsoft.com/en-gb/download/details.aspx?id=50040
Hi i am using c# code for creating xlsx file. i have added the reference to my bin for Microsoft.Office.Interop.Excel Version 12.0.0.0
It Works ok on my local machine. But when i upload it to the server it throws the error in the page where i am creating the xlsx file
"Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
"
can anybody plz help
You are getting the error because excel isn't installed on the server.
You shouldn't be automating Office in ASP.NET. It can lead to myriad performance and scale issues on your server. Office itself is designed for interactive desktop usage, not unattended execution in a non-GUI app. Here is the authoritative reference from MS on the matter:
http://support.microsoft.com/kb/257757
With that being said, there are third-party libraries designed specifically for manipulation of Excel in ASP.NET. OfficeWriter is one example:
http://www.officewriter.com
i have a web service that reads data from excel using Microsoft.Office.Interop.Excel. It works fine on my local machine but when i upload it on a server it gives the following error
Server was unable to process request. ---> Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005.
i googled and tried to follow the suggestion of DCOMCNFG-> component services-> computers-> my computer-> com+ appications but then i dont find the Microsoft excel to change rights.
Office 2003 is installed in server and file i am trying to open is 2003 too.
Please help!!
Thanks
You won't find Excel, you'll have to find the matching CLSID and alter the Activation/Launch permissions.
Standard Disclaimer: Unattended execution of office on the server is not recommended by Microsoft, but a lot of us do it happily (myself included).