我正在尝试在没有也不会安装 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 .
有线索吗?
最佳答案
Office Interop 程序集是运行时可调用包装器 (RCW),允许您通过它公开的 COM API 与安装在系统上的 Office 副本进行互操作。
错误消息表明未安装 Excel,这正是我所期望的。您不能在没有 Office 的机器上使用 Interop 程序集。
关于c# - 创建 Excel 应用程序时出现 COM 异常 80040154,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13660938/