Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE))

孤者浪人 提交于 2019-11-28 10:41:28
Vladimir Shiyanov

Using DCOMCNFG.exe. Open it and go to: Component Services -> Computers -> My Computer -> DCOM Config -> Microsoft Excel Application.

Open the properties, select Identity tab and select the interactive user.

I found this article which talks more about this issue in depth If this helps, error “80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE))” could occur due to following reasons:

  1. The machine has a high CPU load and the process takes a long time to start and fails to execute the CoRegisterClassObjects() in less than 120 seconds.
  2. The COM server doesn't register for the right class IDs.
  3. The COM server is currently stopping and there is a race condition between CoCreateInstance and the COM server stopping part.
  4. There is a security problem in the way the COM server is started (this page seems to suggest misspelled passwords or lacking the "Login as Batch Job" privilege for "Run As.." COM servers, but anyway I would suggest re-verifying this information for your specific configuration)

https://blogs.msdn.microsoft.com/adioltean/2005/06/24/when-cocreateinstance-returns-0x80080005-co_e_server_exec_failure/

I fixed this issue with this solution: right click on Component Services/Computers/DCOM Config/Microsoft Word97 - 2003 Document properties/General Tab

set Authentication Level:None

Same problem was solved for me by "allowing desktop interaction" for the service. (in tomcat6w config tool on Log On tab)

I found the solution elsewhere.

Doing the following did solve my problem:

Using DCOMCNFG.exe. Open it and go to: Component Services -> Computers -> My Computer -> DCOM Config -> Microsoft Excel Application. Open the properties, select Identity tab and select the interactive user.

BUT - the problem came back every few minutes !

After hours of trying to figure out the cause, I noticed my server had hundreds of opened WINWORD.EXE processes. This caused a memory issue which leaded to the exception from hresult 0x80080005 error.

Well, stupidly enough, I forgot to write the code to close the interop application. Once I fixed that, the error was gone.

doc.Close(false);
Marshal.ReleaseComObject(doc);
word.Quit();
Marshal.ReleaseComObject(word);

Try to add Thread.Sleep Method, such as Thread.Sleep(2000) for 2 seconds after workBook.open and workBook.SaveAs two methods. If your Excel file has a lot of formats, try to extend few more seconds.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!