Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Retrieving the COM class factory for component.... error: 80070005 Access is denied." (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

Tags:

asp.net

excel

iis

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();
        }
    }
}

Its giving me following error

 "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)).

System Configuration:

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) creating Desktop application under the path "C:\Windows\SysWOW64\config\systemprofile" 2)setting full permission/control for Microsfot.EXcelApplicaiton in DCOMCNFG 3)Killing all excel instances in Task Manager

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.

like image 889
Ram Avatar asked Jul 22 '13 10:07

Ram


3 Answers

  1. Make sure that you have Office runtime installed on the server.
  2. If you are using Windows Server 2008 then using office interops is a lenghty configuration and here are the steps.

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

  • 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+ Configuration

  • 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.Change the security settings of Microsoft Excel Application in DCOM Config.

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

See the posts here: Error while creating Excel object , Excel manipulations in WCF using COM

like image 149
bot Avatar answered Nov 17 '22 02:11

bot


Sometimes, you create new application pool and cann't solve it via DCOMCNFG. Then there is another method to do:

Set the Identity (Model Name) of application pool to LocalSystem.

I don't know the root cause, but it solve my problem one time.

like image 41
Luis Sérgio Avatar answered Nov 17 '22 02:11

Luis Sérgio


Too late to respond. But, if this helps someone who is still facing the issue. I got this fixed by:

→ Set site on dedicated pool instead of shared one.

→ Enable 32 bit application support.

→ Set identity of the application pool to LocalSystem.

like image 12
Hardik V. Avatar answered Nov 17 '22 02:11

Hardik V.