MS Word interop behavior

0

I am working on a Windows app that uses MS Word interop to generate reports. Environment is Windows 8.1 64-bit, Visual Studio 2013, Word 2013; the app is written in C#. I'm experiencing unpredictable behavior with Word; sometimes it declines to process basic commands (ie SaveAs) and returns the error "Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))". Typically I close the instance of Word, re-run the application and things work fine. Of course I'm concerned about using this app in a production environment.

Here is the outline of how I'm using Word from C#:

word = new Application(); word.Visible = true;
doc = word.Documents.Add(docTemplatePath);
try { File.Delete(docPath); } catch { }
doc.SaveAs2(docPath);
// Populate the doc
doc.Save(); word.Quit(); Marshal.FinalReleaseComObject(word);

Any ideas or experience on this is much appreciated!

c#
ms-word
office-interop
asked on Stack Overflow Feb 12, 2014 by Hank Brandenburg • edited Apr 15, 2014 by Kara

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0