Error 80080005 (CO_E_SERVER_EXEC_FAILURE) when Accessing Microsoft Word COM Object in C# Application on Windows Server

86 views Asked by At

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.

2

There are 2 answers

0
Eugene Astafiev On

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:

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.

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.

0
Todayboy On

Thank the Lord! I found the solution. Here's how:

  1. Begin by running 'mmc -32'.
  2. Go to File > Add Remove Snap-in > Component Services > Add > OK.
  3. In Console Root, navigate to Component Services > Computers > My Computer > DCOM Config.
  4. Find 'Microsoft Word Previewer' (not Microsoft Word this time, I did settings below to Microsoft word anyway) and right-click to select Properties. What I am going to do below is going to be like what other people suggested to do:
    • In the General tab, set Authentication Level to None.
    • In the Security tab, under 'Launch and Activation' and 'Access Permissions,' grant rights to IIS_IUSRS.
    • In the Security tab, under 'Configuration Permissions,' select 'Customize,' add 'IIS_IUSRS,' and give it 'Full Control.'
    • In the Identity tab, select the interactive user.