Search code examples
c#-4.0powerpointoffice-interopcom-interop

Using inropservices.powerpoint in windows service


I have a windows service which activates Interop powerpoint Application class. It works fine using console but when I try to run it as a windows service on my server (Windows Server 2012) it throws COMException when i use app.open method When I run the windows service on my pc it also works fine NOTE: I've installed Microsoft Office 2013 on my server, and added a Desktop folder in C:\Windows\System32\config\systemprofile and in SystemWOW64

Exception details: System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component

Thanks in advance


Solution

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

    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.