Categories
asp.net excel iis

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

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.