我正在尝试在没有也不会安装 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 位的,我复制了应用程序 exe 旁边的 excel Interop dll.我还安装了 O2010PIA.
both systems are 32bits, and I've copied the excel Interop dll next to application's exe. I've also installed O2010PIA.
有什么线索吗?
Office 互操作程序集是运行时可调用的包装器 (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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!