1

I built WCF solution about reporting by using MS-Word 2003 API(Microsoft.Office.Interop.Word) but I got this error :

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)

I don't know why this API call RPC Service and Does it support Word2003 concurrent generating in on web server

Thanks in advance

3 Answers 3

1

Word automation in server side (without UI) is not supported, and leads to very strange problems. You better use the OpenXml libraries for creating word documents.

0

Use of any of the Office products from a service of any kind is unsupported, may violate your license, and worse, just plain doesn't work properly. These are desktop applications, and were written with the assumption that they are being used by a single person, at a desktop computer. Run them in a server, and you violate a large number of assumptions.

-1

We had the same problem, and then we switched to generating word documents in xml (Word Processing ML). It turned out very well.

But, as an alternative you could probably get away by creating a windows service (not web service). Windows service with proper rights would probably be able to use Word process.

You also need to check DCOM settings on server: ControlPanel -> ComponentServices -> Computers -> MyComputer -> DCOM Config -> Microsoft Office Word... then open properties and check the Security and Identity used to run Word.

If there's further problems (as there probably will be with interop) there's further help to be found regarding the registry CLASSID etc, but wait 'till you get there (we didn't move to xslt's for generating word xml without a reason :) ).

4
  • 2
    "If there's further problems..." there will be. Word does not change its way of working when there is no UI, and if it tries to ask the user a question with a dialog the application will lock because nobody will see it. Furthermore, many times it will not close gracefully and will remain in memory, wasting resources till your web server or windows service goes down, and so on... Use automation at client side only... but only when there is no alternative method!
    – jmservera
    Sep 20, 2010 at 11:26
  • Yes, agreed... there's always a workaround - for instance, we killed word process manually, etc... but as you've said there's no way to interact with GUI dialog boxes (there is, but that would be too much), and that's the final reason why we gave up automation. I recommend switching to WordprocessingML as well...
    – veljkoz
    Sep 20, 2010 at 16:38
  • @John Saunders - -1 for providing an alternative? It can be done, it is being done - I didn't say it's a good solution, but it's an option. As you can read - I don't suggest it as well, but sometimes there are cases where you don't have time to implement it the right way, and have to 'hack' it, if only for temporarily...
    – veljkoz
    Nov 22, 2010 at 20:59
  • the alternative is worse than the problem. Office application should never be used from a service. Period. Nov 23, 2010 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.