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

6

我正在尝试在一台没有安装 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位的,我已经将Excel Interop dll复制到应用程序的exe旁边。我还安装了O2010PIA

有任何线索吗?

2个回答

12

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

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


3

1
第二个链接(微软建议不安装Office)已经失效。 - trebor
1
感谢提醒!时间总是会打破链接的恶习。已用archive.org的版本替换原始链接。 - Lauri Harpf

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接