I am having trouble with my application if it doesn't close properly. My application opens word using "Word.Application", if my application throws and exception before reaching the end it leaves a MS Word process running in the task manager.
I would like to be able to check for any instances of Word running in the Task Manager and close them from my application. The logic is if my app is running and word is already open the application can close that instance of Word before doing the work it needs too.
I have looked for an answer online and nothing is working. I tried calling GC.Collect(obj) and Marshal.FinalReleaseCOMObject(obj) but that hasn't worked for me. I would love something that works like "Using...End Using", that way if the program throws an exception it will automatically dispose of Word. But I don't know code well enough to implement that.
Any help is appreciated.
Hmm... I feel like I have more questions than answers. If you find my reply helpful please mark as Answer below. Thanks.