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.
Better is to move to Open XML or you can configure as below
Com+ Configuration
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
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With