本文介绍了服务器执行失败(来自 HRESULT 的异常:0x80080005 (CO_E_SERVER_EXEC_FAILURE))的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Microsoft.Office.Interop.Excel.Workbook 类在服务器端将 .xls 文件转换为 .xlsx 文件,如下所示:

I am trying to convert a .xls file to an .xlsx file on the server-side using Microsoft.Office.Interop.Excel.Workbook class as follows:

 workBook.SaveAs("FILENAME_HERE", XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlNoChange, Microsoft.Office.Interop.Excel.XlSaveConflictResolution.xlLocalSessionChanges, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

我收到以下错误:

Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)). : System.Runtime.InteropServices.COMException (0x80080005): Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
   at System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(RuntimeType objectType)
   at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(RuntimeType serverType)
   at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, Boolean bNewObj)
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Activator.CreateInstance(Type type)
   at CALLING_METHOD_IN_MY_LIBRARY_HERE...

问题是这个错误只发生在登台服务器上;在我的本地机器上它工作正常.

The problem is that this error occurs only on the staging server; on my local machine it works fine.

我在登台服务器上尝试过的事情:

Things that I have tried on the staging server:

  1. **1) 运行 dcomcnfg 打开组件服务

2)展开组件服务->"计算机->"我的电脑->"DCOM配置

2) Expand Component Services "->" Computer "->" My Computer "->" the DCOM configuration "

3) 找到Microsoft Excel 应用程序".

3) Find the "Microsoft Excel application."

4) 右键打开属性对话框

4) Right to open the Properties dialog box

5) 点击安全"标签,

5) Clicked on the "Security" tab,

6)启动和激活权限、配置权限、添加权限-身份在管理员用户(此用户)、交互用户和启动用户下运行

6) "Launch and Activation Permissions, configure permissions, have added permissions - Identity run under Adminstrator user (This User), Interactive User and Launching Users

7).启动和激活权限 + 访问权限 + 配置权限 => 添加 IIS_IUSRS + 完全控制网络服务**

7). Launch and activation permissions + Access Permissions + Configuration Permissions => added IIS_IUSRS + Network Service with Full Controll**

2.在我的本地机器上更改了将 .xls 文件从任何 CPU"转换为x86"的项目的构建,并在服务器上发布了这个库.

有人想出如何解决这个问题吗?我现在正在努力解决这个问题 2 天.

Did someone figured out how to fix this problem? I am struggling on fix this issue for 2 days now.

推荐答案

使用 DCOMCNFG.exe.打开它并转到:组件服务 -> 计算机 -> 我的电脑 -> DCOM 配置 -> Microsoft Excel 应用程序.

Using DCOMCNFG.exe. Open it and go to:Component Services -> Computers -> My Computer -> DCOM Config -> Microsoft Excel Application.

打开属性,选择身份选项卡并选择交互式用户.

Open the properties, select Identity tab and select the interactive user.

这篇关于服务器执行失败(来自 HRESULT 的异常:0x80080005 (CO_E_SERVER_EXEC_FAILURE))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 19:49