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

Biz*_*han 5 c# com interop com-interop office-interop

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

using EXCEL = Microsoft.Office.Interop.Excel;
...
EXCEL.Application app = new EXCEL.Application();//Exception thrown here
Run Code Online (Sandbox Code Playgroud)

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

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)).
Run Code Online (Sandbox Code Playgroud)

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

任何铅?

Joe*_*Joe 8

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

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