An exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll but was not handled in user code

Exception from HRESULT: 0x80070005 (E_ACCESSDENIED) - Error : 80070005 Access is denied.

An exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll but was not handled in user code

Additional information: 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)).

This Issue Is Occurring
When I tried to download excel file on cloud server! I debugging this code on the cloud server and find out, error is occurring at the time of creation of Microsoft.Office.Interop.Excel.Application object i.e.

using Excel = Microsoft.Office.Interop.Excel;
Excel.Application excel = new Excel.Application();

This is a COM permissions problem! I used forms authentication!

Firstly search Desktop folder in the below path – CREATE Desktop folder, if not exist!

For 64-bit (x64) - create this folder: C:\Windows\SysWOW64\config\systemprofile\Desktop
For 32-bit (x86) - create this folder: C:\Windows\System32\config\systemprofile\Desktop

Otherwise try to resolve below follow these steps - It might help you!
Solutions –
1.     Start => Run => dcomcnfg
2.     Open to Component Services => Component Services => Computers => My Computer => DCOM Config
3.     Find “Microsoft Excel Application”
4.     Right click => Properties
5.     Go to “Security Tab” and Edit the “Customize” radio buttons so that <Machine_name >/IIS_IUSRS could have rights for launch and access.
6.     Go to “Identity Tab” and choose “The interactive user”
7.     Apply changes and try again
References –

I hope you are enjoying with this post! Please share with you friends. Thank you!!

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - and
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
Post a Comment Powered by Blogger.
ASK Questions