Reputation: 1
I am creating a Windows service using Microsoft.Office.Interop.Word dll to create a new word document and enter some text inside it. But it is not working in Windows Service. When I used the same code and run it as a Console Application, it is working.
How can I run COM Interop dll using Windows Service?
Thanks in advance
Tried - I am creating a Windows service using Microsoft.Office.Interop.Word dll to create a new word document and enter some text inside it. But it is not working in Windows Service.
Expecting - To Open Word using Microsoft.Office.Interop.Word dll by creating windows service
Upvotes: 0
Views: 293
Reputation: 49455
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 possible workaround you may consider using the Open XML SDK if you deal with open XML documents, see Welcome to the Open XML SDK 2.5 for Office for more information. Or just any third-party component designed for the server-side execution.
Upvotes: 0