COM异常80040154创建Excel应用程序时

时间:2012-12-01 15:40:03

标签: c# com interop com-interop office-interop

我正在尝试在没有安装Office的服务器上运行我的应用程序。

using EXCEL = Microsoft.Office.Interop.Excel;
...
EXCEL.Application app = new EXCEL.Application();//Exception thrown here

代码在我自己的系统上工作正常,但在服务器上它提供了以下异常:

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

两个系统都是32位,我在应用程序的exe旁边复制了excel Interop dll。我还安装了O2010PIA

任何领导?

2 个答案:

答案 0 :(得分:8)

Office Interop程序集是可运行时调用的包装程序(RCW),允许您通过它公开的COM API与系统上安装的Office副本进行互操作。

错误消息表明未安装Excel,正是我所期望的。您不能在没有Office的计算机上使用Interop程序集。

答案 1 :(得分:3)

  

我正在尝试在没有和将要的服务器上运行我的应用程序   没有安装Office。

正如Joe所说,你需要安装Excel for Interop才能工作。如果您对此不满意,请考虑third-party alternatives。一般来说,Microsoft does not recommend installing Office on your server and using it with Interop - 如果说,它将起作用(至少大部分时间)。

相关问题