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

15

本文介绍了创建 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

C# 中的多播委托奇怪行为?
Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)...
2023-11-11 C#/.NET开发问题
6

参数计数与调用不匹配?
Parameter count mismatch with Invoke?(参数计数与调用不匹配?)...
2023-11-11 C#/.NET开发问题
26

如何将代表存储在列表中
How to store delegates in a List(如何将代表存储在列表中)...
2023-11-11 C#/.NET开发问题
6

代表如何工作(在后台)?
How delegates work (in the background)?(代表如何工作(在后台)?)...
2023-11-11 C#/.NET开发问题
5

没有 EndInvoke 的 C# 异步调用?
C# Asynchronous call without EndInvoke?(没有 EndInvoke 的 C# 异步调用?)...
2023-11-11 C#/.NET开发问题
2

Delegate.CreateDelegate() 和泛型:错误绑定到目标方法
Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)...
2023-11-11 C#/.NET开发问题
14