問題描述
Word 2016 自動化生成“錯誤:80080005 服務器執行失敗” (Word 2016 automation generates "error: 80080005 Server execution failed")
我在 Windows 7(終極版)開發人員機器上安裝了 Office 2016 預覽版以及 VS 2010。我有以下簡單的 C# WinForms 應用程序,它嘗試通過自動化創建 Word 文檔:
using Word = Microsoft.Office.Interop.Word;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Word.Application word = new Word.Application(); // <‑ Causes exception
...
}
}
應用程序生成以下錯誤:
附加信息:檢索具有 CLSID {000209FF‑0000‑0000‑C000‑000000000046} 的組件的 COM 類工廠失敗,原因是以下錯誤:80080005 服務器執行失敗(HRESULT 異常:0x80080005 (CO_E_SERVER_EXEC_FAILURE))。
上述錯誤的大多數搜索結果涉及人們試圖在實際服務器上運行(早期)版本的 Office 程序的情況.
我錯過了什麼嗎?
PS:Office 2016 本身就是一頭奇怪的野獸,因為它在添加/刪除程序中沒有任何條目,而且它的 部署工具只有選擇要從下載中排除的應用程序的選項,沒有修復現有安裝的選項。
參考解法
方法 1:
I tried to mimic your system as much as possible, by creating a WinForms project and targeting .NET 4.0. I'm able to create a Word.Application object without any exception.
I'm pretty sure that you are getting the error due to a corrupt Windows Registry, likely corrupted by Office itself.</p>
There are 3 more things you can do before giving up:
- Go here and follow the steps to clean up the Registry using scanreg /fix
- Uninstall every Office product, open the Registry and delete EVERY key related to Office, then install 2016 again (make sure to backup all your data first)
- Reinstall Windows.
I worked in an application support position where the application was very integrated with Excel and Word through add‑ins, and I had to research and explain to the development team (another vendor) why this happened and how it can be solved in some cases. Until I found step 1 above and the steps I told you in my first comment to your question, every single case was solved using step 3.
(by Sabuncu、Camilo Terevinto)