COM Exception 80040154 When creating an Excel Application(创建 Excel 应用程序时出现 COM 异常 80040154)
问题描述
我正在尝试在没有也不会安装 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:创建 Excel 应用程序时出现 COM 异常 80040154
基础教程推荐
- c# Math.Sqrt 实现 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- MS Visual Studio .NET 的替代品 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01