2010-09-20 88 views
1

我建立WCF的解決方案有關使用MS-Word 2003的API(的Microsoft.Office.Interop.Word)報告,但我得到這個錯誤:在WCF錯誤中創建MS-Word 2003?

2010-09-17 16:31:39,218 [21] ERROR ERROR [(null)] - Error : Generate 0900000a80395799 
System.Runtime.InteropServices.COMException (0x800706BA): The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) 
    at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) 
    at System.Runtime.InteropServices.CustomMarshalers.EnumeratorViewOfEnumVariant.MoveNext() 
    at FactoryService.Generator.Generate(Task& task, IDfSession& mySession) 
    at FactoryService.Generator.Generate(Object t) 
2010-09-17 16:31:49,578 [22] ERROR ERROR [(null)] - Error generator timeout 0900000a80395799 
2010-09-17 16:31:49,812 [14] ERROR ERROR [(null)] - Error : Generate 0900000a80395799 
System.Runtime.InteropServices.COMException (0x800706BF): The remote procedure call failed and did not execute. (Exception from HRESULT: 0x800706BF) 
    at Microsoft.Office.Interop.Word.ApplicationClass.get_Documents() 
    at FactoryService.Generator.Generate(Task& task, IDfSession& mySession) 
    at FactoryService.Generator.Generate(Object t) 
2010-09-17 16:31:50,046 [18] ERROR ERROR [(null)] - Error : Generate 0900000a80395799 
System.Runtime.InteropServices.COMException (0x800706BA): The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) 
    at Microsoft.Office.Interop.Word.ApplicationClass.get_Documents() 
    at FactoryService.Generator.Generate(Task& task, IDfSession& mySession) 
    at FactoryService.Generator.Generate(Object t) 
2010-09-17 16:31:50,968 [22] ERROR ERROR [(null)] - Error generator timeout 0900000a80395799 
2010-09-17 16:31:50,984 [10] ERROR ERROR [(null)] - Error : Generate 0900000a80395799 
System.Runtime.InteropServices.COMException (0x800706BE): The remote procedure call failed. (Exception from HRESULT: 0x800706BE) 
    at Microsoft.Office.Interop.Word.Documents.Open(Object& FileName, Object& ConfirmConversions, Object& ReadOnly, Object& AddToRecentFiles, Object& PasswordDocument, Object& PasswordTemplate, Object& Revert, Object& WritePasswordDocument, Object& WritePasswordTemplate, Object& Format, Object& Encoding, Object& Visible, Object& OpenAndRepair, Object& DocumentDirection, Object& NoEncodingDialog, Object& XMLTransform) 
    at FactoryService.Generator.Generate(Task& task, IDfSession& mySession) 
    at FactoryService.Generator.Generate(Object t) 

我不知道爲什麼這個API調用RPC服務並且它支持Word2003中併發發生在Web服務器上

感謝事先在服務器端(無UI)

回答

1

字自動化不支持,並導致非常奇怪的問題。您最好使用OpenXml庫來創建Word文檔。

-1

我們遇到了同樣的問題,然後我們切換到xml生成word文檔(Word Processing ML)。結果非常好。

但是,作爲替代方案,您可能會通過創建Windows服務(而不是Web服務)逃脫。具有適當權限的Windows服務可能會使用Word進程。

您還需要檢查服務器上的DCOM設置:ControlPanel -> ComponentServices -> Computers -> MyComputer -> DCOM Config -> Microsoft Office Word ...然後打開屬性並檢查用於運行Word的安全和身份。

如果還有其他問題(因爲可能與interop有關)還有關於註冊表CLASSID等方面的進一步幫助,但請等待,直到你到達那裏(我們沒有移動到xslt's來生成沒有原因:))。

+2

「如果還有其他問題......」將會出現。當沒有UI時,Word不會改變其工作方式,並且如果它嘗試用對話框詢問用戶的問題,則應用程序將被鎖定,因爲沒有人會看到它。此外,很多時候它不會優雅地關閉,並且會保留在內存中,浪費資源直到您的Web服務器或Windows服務關閉,等等......僅在客戶端使用自動化......但只有當沒有其他方法時! – jmservera 2010-09-20 11:26:15

+0

是的,同意......總有一種解決方法 - 例如,我們手動殺死了文字處理等等......但正如你所說的,沒有辦法與GUI對話框交互(有,但那會太多),這就是我們放棄自動化的最終原因。我建議切換到WordprocessingML以及... – veljkoz 2010-09-20 16:38:21

+0

-1建議使用任何類型的服務的Word。 – 2010-11-22 20:29:45

0

從任何類型的服務中使用任何Office產品都是不受支持的,可能會違反您的許可證,更糟的是,只是普通的方式無法正常工作。這些是桌面應用程序,並且是在假設他們正在單個人使用桌面計算機的情況下編寫的。在服務器中運行它們,並且違反了大量的假設。