Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

COM Exception 80040154 When creating an Excel Application

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?

like image 603
Bizhan Avatar asked Dec 01 '12 15:12

Bizhan


2 Answers

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.

like image 163
Joe Avatar answered Nov 02 '22 17:11

Joe


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).

like image 38
Lauri Harpf Avatar answered Nov 02 '22 18:11

Lauri Harpf