爲什麼這會導致excel被打開?爲什麼openfiledialog會導致excel被添加到任務管理器進程?
OpenFileDialog openFileDialog1 = new OpenFileDialog();
DialogResult result = openFileDialog1.ShowDialog(); // Show the dialog.
if (result == DialogResult.OK) // Test result.
{
//EXCEL.EXE *32 is now showing in the task manager!
我從openfiledialog
選擇一個XLSX
文件,如上圖所示,我看到在任務管理器的進程。
可有人告訴我這怎麼可能?
如果一切都失敗了,單步通過代碼!它應該很快顯示哪條線路導致問題。此外,Excel返回的任何對象也必須在完成時通過ReleaseComObject發佈,例如。 xlWorkBook,xlWorkSheet,xlWorkSheet.get_Range,EmailList.Cells。想念任何一個Excel將保持開放。 – Will 2012-04-01 19:45:19
ps。另外,你的清理代碼應該在finally塊中,以保證它被調用,而不管成功或異常。 – Will 2012-04-01 19:48:22
非常感謝。你可以請看看編輯的問題,我想我找到了原因爲什麼 – 2012-04-01 20:10:50