创建Excel应用程序时出现COM异常80040154 [英] COM Exception 80040154 When creating an Excel Application
问题描述
我正在尝试在没有也不会安装Office的服务器上运行我的应用程序.
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)).
两个系统都是32位的,并且我已经将Excel Interop dll复制到了应用程序的exe旁边.我还安装了 O2010PIA .
both systems are 32bits, and I've copied the excel Interop dll next to application's exe. I've also installed O2010PIA.
任何线索?
推荐答案
Office Interop程序集是可在运行时调用的包装器(RCW),允许您通过其COM API与系统上安装的Office副本进行互操作.暴露.
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.
错误消息表明未安装Excel,完全符合我的期望.没有Office的计算机上不能使用Interop程序集.
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.
这篇关于创建Excel应用程序时出现COM异常80040154的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!