用子线程调用excel,用尽网上所有释放excel方法...依然无解!!!
窗体一按钮用了个线程Thread t1 = new Thread(new ThreadStart(excelOp));
t1.Start();
线程调用以下方法
excelOp()
{
Microsoft.Office.Interop.Excel.ApplicationClass excel = new ApplicationClass();
Workbook wb = excel.Workbooks.Open(@"E:\Book1.xlsx", Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
.........(一堆处理,只开了workbook,其它啥sheet都不敢用)
wb.close(false,false,Type.missing);
System.Runtime.InteropServices.Marshal.ReleaseComObject(wb);
wb = null;
excel.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(excel);
excel = null;
}
最后在退出窗体的按钮里加个 GC.Collect();
还是不行...崩溃了..
直接写了个方法 杀进程 没办法了.....
大家再帮看看是不是代码问题
--------------------编程问答-------------------- 进程退出的时候,应该 就会释放掉了吧 --------------------编程问答-------------------- wait..
补充:.NET技术 , C#