也许尝试设置
doc = null并致电
GC.Collect()
编辑,不是我自己的代码,我忘了我从哪里得到的,但这是我用来处理Excel的东西,它可以完成工作,也许您可以从中收集一些信息:
public void DisposeExcelInstance(){ app.Displayalerts = false; workBook.Close(null, null, null); app.Workbooks.Close(); app.Quit(); if (workSheet != null) System.Runtime.InteropServices.Marshal.ReleaseComObject(workSheet); if (workBook != null) System.Runtime.InteropServices.Marshal.ReleaseComObject(workBook); if (app != null) System.Runtime.InteropServices.Marshal.ReleaseComObject(app); workSheet = null; workBook = null; app = null; GC.Collect(); // force final cleanup!}


