简体   繁体   中英

RPC_E_SERVERFAULT when automating Microsoft Word

I'm creating word documents from templates (.dot) via Microsoft.Office.Interop.Word . The code below works on some templates but not on others: where it doesn't work it throws an RPC_E_SERVERFAULT exception. What is this about, what can be the cause, and how could I fix it? (The exception occurs on the second line.)

wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
wordDoc = wordApp.Documents.Add(ref oTemplate, ref newTemplate, ref docType, ref isVisible);
wordApp.Visible = false;
wordDoc.Activate();

You will hate me and downvote me probably but in all my .NET work experience working with the COM Interop is a PIA (pun intended / PIA also means Primary Interop Assemblies).

Usually the performance is so bad that makes the whole thing unacceptable. So we resorted to buying a 3rd party, managed, non-Office-dependent library that does the same thing WAY faster.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM