C# MSOffice Interop Word will not kill winword.exe

cinteropzombie-process

I'm writing an application that needed a MSWord document parser.

I'm using Microsoft.Office.Interop.Word.Document to extract the texts from the documents, but even if i use doc.Close() the document, from taskManager i can see that winword.exe are not killed, and after parsing a couple dozens documents it eats up some much resources.

is close() the wrong method?

please help me and point me to the right direction on how to terminate these processes properly. =)

~~~update~~~

Thanks for all the help. I use the app.quit() and also ran a loop that checks for the process and problem solved! =)

Best Answer

Are you calling Application.Quit , additionally since you're doing Interop it may be worthwhile to release the RCW wrapper.

So basically something like:

yourWordAppObject.Quit();
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(yourWordAppObject);

Note some folks use: ReleaseComObject but there are some potential pitfalls

Related Topic