locked
Excel exe is not getting closed ,even if we do GC.COllect relesing com object in asp.net RRS feed

  • Question

  • User-730570167 posted

    GC.Collect()
    GC.WaitForPendingFinalizers()
    FinalReleaseComObject(xlSheets)
    FinalReleaseComObject(xlBook)
    FinalReleaseComObject(xlBooks)
    FinalReleaseComObject(xlExcel)
    FinalReleaseComObject(wrksht)
    'FinalReleaseComObject(xlCells)
    xlExcel = Nothing
    xlBooks = Nothing
    xlBook = Nothing
    xlSheets = Nothing
    wrksht = Nothing
    xlCells = Nothing

    Tuesday, April 17, 2012 1:14 AM

Answers

  • User1630798415 posted

    try with the following

    // Garbage collecting
    GC.Collect();
    GC.WaitForPendingFinalizers();
    // Clean up references to all COM objects
    // As per above, you're just using a Workbook and Excel Application instance, so release them:
    workbook.Close(false, Missing.Value, Missing.Value);
    Marshal.FinalReleaseComObject(workbook);
    Marshal.FinalReleaseComObject(xlApp);
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 18, 2012 7:16 AM

All replies

  • Tuesday, April 17, 2012 1:18 AM
  • User1630798415 posted

    try with the following

    // Garbage collecting
    GC.Collect();
    GC.WaitForPendingFinalizers();
    // Clean up references to all COM objects
    // As per above, you're just using a Workbook and Excel Application instance, so release them:
    workbook.Close(false, Missing.Value, Missing.Value);
    Marshal.FinalReleaseComObject(workbook);
    Marshal.FinalReleaseComObject(xlApp);
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 18, 2012 7:16 AM