NetOfficeFw / NetOffice

🌌 Create add-ins and automation code for Microsoft Office applications.
MIT License
697 stars 143 forks source link

Unable to create instance of:<Word.Application> This is typically because you have no access to the desktop subsystem from a Windows Service/IIS module in default configuration because it is running in a restricted context/principal. #270

Closed abinscjames closed 4 years ago

abinscjames commented 4 years ago

We are trying to create an application(Win Service) to automate WinWord.exe process for some tasks. When we deployed as a console application all works fine. But when we host the same as an WinService, we are encountering this issue "Unable to create instance of: This is typically because you have no access to the desktop subsystem from a Windows Service/IIS module in default configuration because it is running in a restricted context/principal."

In this service we are trying to open word file and save. Word.Application apps = new Word.Application(); apps.DisplayAlerts = Word.Enums.WdAlertLevel.wdAlertsNone; apps.Documents.Open(filename); Issue raises at here.

Can you provide some solution to fix this issue.

jozefizso commented 4 years ago

Did you configure Windows Service for running Office Automation?

https://support.microsoft.com/en-us/help/257757/considerations-for-server-side-automation-of-office

https://www.ryadel.com/en/office-interop-dcom-config-windows-server-iis-word-excel-access-asp-net-c-sharp/

jozefizso commented 4 years ago

Please, reopen the issue when you will provide more information.