I have the following code, I wonder if I need to release ComObject
manually or the garbage collector will release it for me?
wordApp = new Word.Application();
wordDoc = new Word.Document();
// some stuff
wordDoc.Close(null, null , null);
wordApp.Quit();
if(System.Runtime.InteropServices.Marshal.IsComObject(wordDoc))
System.Runtime.InteropServices.Marshal.ReleaseComObject(wordDoc);
wordDoc = null;
if (System.Runtime.InteropServices.Marshal.IsComObject(wordApp))
System.Runtime.InteropServices.Marshal.ReleaseComObject(wordApp);
wordApp = null;
Is the above code correct or shouldn't I use Marshal.IsComObject
in the end?