I am working with Windows Service written in C#. Through this Windows Service I am automating Excel in a programmatic way.
Excel.Application excel = Excel.Application();
This code was working fine with all versions of Excel (2003, 2007, 2010, 2013). Recently I have installed Office 365 in my machine. Suddenly I am getting below exception when I automate the Excel using above call:
Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
Can anyone let me know, is there any special consideration should be taken when automating the Office 365 Excel via Windows Service?
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.
You may consider using the Open XML SDK instead, see EWS Managed API, EWS, and web services in Exchange for more information. Or any third-party components designed for the server-side execution.
User contributions licensed under CC BY-SA 3.0