Code runs on development server but not on IIS

1.2k views Asked by At

I have a web application where user run queries(through web interface) and gets output in excel format. Sometimes this output comprises of more than 300k records. The user needs this data for further research.

Now in order to speed up the dynamic excel creation with such large volume of data, we are using "Microsoft.Office.Interop.Excel" COM object.

Our code works completely fine on the in-built asp.net development server. However, when hosted on the IIS, it gives us "Access is Denied" error (exact error is as shown below).

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

I have given all the rights to the IIS user but still this is not working. I have tried Windows Server 2012 R2 as well as Windows 7 OS and it doesn't work on both of them.

I have made changes to the "DCOMCNFG" and granted access to the web users under the "COM Security" tab also.

What are some additional steps I can take to make this work?

4

There are 4 answers

0
milan m On BEST ANSWER

I have decided to give up on using COM object for Excel operation on the server. Instead, I have decided to use EPPlus open office XML SDK for generation of Excel files. This works without any additional security permission requirement on the server.

9
Alexey Nis On

This is a COM permissions problem.

Start > Run > dcomcnfg

Navigate to Component Services > Computers > My Computer > DCOM Config

Locate the Microsoft Excel Application

Right click > Properties

On the security tab: Select Security under Launch and Activation Permissions and click Edit…

Add the account under which the site is running (eg: Network Service) and assign Local Launch & Local Activation permissions

Source

Also the ASP.NET Authentication should be enabled.

0
Poiter On

I think for this to work, office has to be installed on the server. So if this is not the case, install Office on the server. (alternative is to use OpenXml http://www.microsoft.com/en-us/download/details.aspx?id=30425)