I'm encountering a perplexing issue with my C# application that utilizes Microsoft Word COM objects. While the application operates smoothly in debug mode in visual studio debug mode with settings below: Component Services>…Word > Identity > Select "The launching user" in the windows server, I'm facing persistent errors upon deploying it the same server and hosting by IIS.
The specific error message I'm encountering is:
"Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE))."
Here's what I've attempted so far:
⁃ Application pool changed identity to all possible selection, including the ultimate one I want to use a user named Administrator
⁃ Component Services> Identity tab > selected the interactive user.
⁃ "Launch and Activation” and “Access Permissions”: added all local activity and control to: Administrator user (This User) , IIS_IUSRS, Anonymous, Everyone, Guests, Interactive, Network , System
⁃ right click on Component Services/Computers/DCOM Config/Microsoft Word97 - 2003 Document properties/General Tab, set Authentication Level:None
⁃ Go to Security and select "Customize" under "Configuration Permissions. (If needed you might want to change the other permissions as well, but I didn't need to) Add "IIS_IUSRS" and give it "Full Control".
Now go to "Identity" and select "The interactive user".
While trying all the changes above, I still got either error above or error below while changing the identity in application pool or the word’s properties identity tab in Component Services, nothing work. The another error: “Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).”
While I've come across several posts discussing similar issues, I've diligently tried almost every solution suggested, including various configurations in the application pool settings and Component Services. Despite these efforts, the problem persists. Any fresh insights or alternative approaches would be greatly appreciated.
This is widely spread issue when dealing with automation of MS Word on the server or any service application. Here is what MS states for such cases:
Read more about that in the Considerations for server-side Automation of Office article.
If you deal with open XML documents you may consider using the Open XML SDK instead, see Welcome to the Open XML SDK for Office for more information.