Word 2016 自動化生成“錯誤:80080005 服務器執行失敗” (Word 2016 automation generates "error: 80080005 Server execution failed")


問題描述

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:

  1. Go here and follow the steps to clean up the Registry using scanreg /fix
  2. 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)
  3. 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 SabuncuCamilo Terevinto)

參考文件

  1. Word 2016 automation generates "error: 80080005 Server execution failed" (CC BY‑SA 2.5/3.0/4.0)

#ms-office #ms-word #office-interop #C#






相關問題

什麼是 MS Office 對比算法? (What is the MS Office contrast algorithm?)

在 Office 2007 應用程序中使用 VBA? (Use VBA in Office 2007 Applications?)

複製 Word 腳註 (Copy Word Footnotes)

使用 WebApi 打開辦公文檔並使用 MS Office 保存回站點 (Open office documents with WebApi and save back to the site using MS Office)

用於確定 Windows 和 Office 版本的快速命令或批處理腳本 (quick command or batch script to determine Windows and Office version)

通過 Office 加載項將內容添加到 Outlook 電子郵件正文 (Adding content to an Outlook email body via an Office Add-In)

Word 2016 自動化生成“錯誤:80080005 服務器執行失敗” (Word 2016 automation generates "error: 80080005 Server execution failed")

Office 2016 查找激活日期 (Office 2016 find activation date)

Word 2007 文件啟動新窗口而不是顯示內聯 (Word 2007 files launching new window instead of displaying inline)

將 A1 公式和數組轉換為 L1C1 公式,反之亦然 (convert A1 formula and Array into L1C1 formula and vice-versa)

.NET C# Office Shared Add In WCF Service 引用異常 (.NET C# Office Shared Add In WCF Service reference exception)

從顯示“錯誤!超鏈接引用無效”的 MS Word 字段中恢復 URL (Recover URL from MS Word fields showing "Error! Hyperlink reference not valid")







留言討論