Answered by:
Windows service throwing E_ACCESSDENIED error

Question
-
I've C# 4.0 windows service running on a Windows 2008 server. It uses MS Excel interop component to read and save excel files on the server. Its throwing following error while doing so:
Retrieving the COM class factory for component… error: 80070005 Access is denied.” (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
I checked the registry and I can see this class Id present over there. Not sure whats the solution for this issue.What permissions am I missing please?
Thanks.
- Moved by Fred Bao Monday, July 13, 2015 8:27 AM Office Develop Related
Friday, July 10, 2015 2:22 AM
Answers
-
Hello,
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution.Read more about that in the Considerations for server-side Automation of Office article in MSDN.
As a workaround you may consider using the Open XML SDK, see Welcome to the Open XML SDK 2.5 for Office for more information. Or just find any third-party components designed for the server-side execution.
- Proposed as answer by Starian chenMicrosoft contingent staff Monday, July 20, 2015 6:53 AM
- Marked as answer by Fei XueMicrosoft employee Monday, July 20, 2015 11:06 AM
Monday, July 13, 2015 9:12 AM
All replies
-
You need to change the security settings of Microsoft Excel Application in DCOM configuration.
Control Panel -> Administrative Tools -> Component Services -> Computers -> My Computer -> DCOM Config -> Microsoft Excel Applications.
There are more explanations given at http://stackoverflow.com/questions/17785063/retrieving-the-com-class-factory-for-component-error-80070005-access-is-de
Friday, July 10, 2015 11:58 AM -
Hi Mitu,
>>It uses MS Excel interop component to read and save excel files on the server.
From this message, this case more related to Excel, So i moved this case to Excel forum for better support.
Have a nice day!
Kristin
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.Monday, July 13, 2015 8:28 AM -
Hello,
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution.Read more about that in the Considerations for server-side Automation of Office article in MSDN.
As a workaround you may consider using the Open XML SDK, see Welcome to the Open XML SDK 2.5 for Office for more information. Or just find any third-party components designed for the server-side execution.
- Proposed as answer by Starian chenMicrosoft contingent staff Monday, July 20, 2015 6:53 AM
- Marked as answer by Fei XueMicrosoft employee Monday, July 20, 2015 11:06 AM
Monday, July 13, 2015 9:12 AM