4
votes

I have an MVC Web API application using Excel related DLL Microsoft.Office.Interop.Excel When I run application from VS 2013, it is running under IIS express and I can send Post request to it successfully through RestClient But when I deploy this application to IIS, after sending Post request, it is giving me below error.

Unexpected Error occured while serving your RequestSystem.UnauthorizedAccessException: 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 Administrator privileges in my machine and I have given all permissions to folder which contains the code. I have also added user IUSR and given all access to the folder having my code.

1
Which IIS version are you using? Have you checked that the app runs as IUSR? - JanneP
@JanneP : IIS version is 10 and OS is windows 10. I don't know how to check if app runs as IUSR. Can you please share the process for same. - Programming Geek
Check the application pool identity in IIS Manager: Application Pools->[YouAppPool]->Advanced Settings. A good MS article covering application pool identities can be found here: iis.net/learn/manage/configuring-security/… - JanneP

1 Answers

3
votes

After reading the App pool identity document shared by JanneP, I have changed application Pool identity from ApplicationPoolIdentity to LocalSystem and now issue got resolved and my application is working perfectly under IIS. enter image description here