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
- 使用 rss + c# 2022-01-01
- CanBeNull和ReSharper-将其用于异步任务? 2022-01-01
- Azure Active Directory 与 MVC,客户端和资源标识同一 2022-01-01
- 为什么 C# 中的堆栈大小正好是 1 MB? 2022-01-01
- 带问号的 nvarchar 列结果 2022-01-01
- 在 LINQ to SQL 中使用 contains() 2022-01-01
- C# 通过连接字符串检索正确的 DbConnection 对象 2022-01-01
- 是否可以在 .Net 3.5 中进行通用控件? 2022-01-01
- Windows 喜欢在 LINUX 中使用 MONO 进行服务开发? 2022-01-01
- 在 C# 中异步处理项目队列 2022-01-01
