2010-09-20 87 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产品都是不受支持的,可能会违反您的许可证,更糟的是,只是普通的方式无法正常工作。这些是桌面应用程序,并且是在假设他们正在单个人使用桌面计算机的情况下编写的。在服务器中运行它们,并且违反了大量的假设。