“检索组件的COM类工厂....错误:80070005访问被拒绝”。 (HRESULT异常:0x80070005(E_ACCESSDENIED)) [英] "Retrieving the COM class factory for component.... error: 80070005 Access is denied." (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

查看:139
本文介绍了“检索组件的COM类工厂....错误:80070005访问被拒绝”。 (HRESULT异常:0x80070005(E_ACCESSDENIED))的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚创建了一个简单的应用程序,并在 IIS6.0 中托管。在代码中,我只是实例化excel对象。

I just created a simple application and hosted in IIS6.0. In code I'm just instantiating excel objects.

using excel = Microsoft.Office.Interop.Excel.Application;

namespace TestHosting
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            excel excelObj=new Microsoft.Office.Interop.Excel.Application();
        }
    }
}

它给我以下错误

 "Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied." (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).

系统配置:

Windows Server 2008,64位的企业版。
service pack 2

Windows server 2008,enterprise edition with 64 bit. service pack 2

我尝试了在互联网上发现的许多可能的解决方案,但没有一个为我工作。

I tried with many possible solutions found on internet,but none of them were worked for me.

我尝试的一些解决方案在

Some solution I tried are below

1)创建桌面应用程序路径C:\Windows\SysWOW64\config\systemprofile
2)在DCOMCNFG
中设置Microsfot.EXcelApplicaiton的完全权限/控制3)在任务管理器中杀死所有excel实例

请帮助我在这方面,这只是示例应用程序,但在我的原始应用程序主要是关于从/到excel读取和写入数据。

Please help me in this regard,this is just sample app but in my original app is mostly about read and writing data from/to excel.

推荐答案


  1. 确保在服务器上安装了Office运行时。

  2. 如果您使用的是Windows Server 2008,那么使用office interops是一个冗长的配置,这里是步骤。

更好的是移动到Open XML或您可以配置如下

Better is to move to Open XML or you can configure as below


  • 安装MS Office Pro最新(我使用了2010 Pro )

  • 创建用户ExcelUser。使用管理组分配WordUser

  • 转到计算机 - >管理

  • 添加具有以下选项的用户

  • 用户选项密码永不过期

  • 密码无法更改

  • Install MS Office Pro Latest (I used 2010 Pro)
  • Create User ExcelUser. Assign WordUser with Admin Group
  • Go to Computer -> Manage
  • Add User with below options
  • User Options Password Never Expires
  • Password Cannot Be Change

Com +配置


  • 转到控制面板 - >管理员 - >组件服务 - > DCOM配置

  • 打开Microsoft Word 97 - 2003属性

  • 一般 - >验证级别:无

  • 安全性 - >自定义所有3个权限以允许每个人

  • 身份 - >此用户 - >使用ExcelUser /密码

  • 启动Excel应用程序以确保一切正常

  • Go to Control Panel - > Administrator -> Component Services -> DCOM Config
  • Open Microsoft Word 97 - 2003 Properties
  • General -> Authentication Level : None
  • Security -> Customize all 3 permissions to allow everyone
  • Identity -> This User -> Use ExcelUser /password
  • Launch the Excel App to make sure everything is fine

3.在DCOM Config中更改Microsoft Excel应用程序的安全设置。

3.Change the security settings of Microsoft Excel Application in DCOM Config.

控制面板 - >管理工具 - >组件服务 - >计算机 - > myComputer - > DCOM配置 - > Microsoft Excel应用程序。

Controlpanel --> Administrative tools-->Component Services -->computers --> myComputer -->DCOM Config --> Microsoft Excel Application.

右键单击获取属性对话框。转到安全性选项卡并自定义权限

Right click to get properties dialog. Go to Security tab and customize permissions

看到这里的帖子:创建Excel对象时出错使用COM的WCF中的Excel操作

这篇关于“检索组件的COM类工厂....错误:80070005访问被拒绝”。 (HRESULT异常:0x80070005(E_ACCESSDENIED))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆