我在 IIS 上有一个 ASP.NET 应用程序。在这个应用程序中,我使用 Excel COM 对象:
using Excel = Microsoft.Office.Interop.Excel;
我使用这个对象:
public Excel.Application ExlApp;
//
public Excel.Workbook ExlWb;
//
public Excel.Worksheet ExlWs;
并像这样摧毁它们:
GC.Collect();
GC.WaitForPendingFinalizers();
Marshal.ReleaseComObject(ExlWs);
ExlWb.Close(Type.Missing, Type.Missing, Type.Missing);
Marshal.ReleaseComObject(ExlWb);
ExlApp.Quit();
Marshal.ReleaseComObject(ExlApp);
因此,它在 Visual Studio 2008 上正常工作。但是!当我仅在 IIS 上启动此应用程序时,Excel 进程无法被破坏!帮助!