0

I am currently using Microsoft.Office.Interop.Excel for a C# windows forms project, but I have been struggling to find answers as to why the excel process continues running in the background even after my code executes.

I have tried almost everything, but nothing has worked - I've used the workbook.Close() and app.Quit(), I've tried setting the values of null to all of the excel objects, using the Marshal.FinalReleaseComObject() and Marshal.ReleaseComObject() methods,I've also tried using the GC.Collect() and GC.WaitForPendingFinalizers(). I ran the application in debug mode and release mode and I also tried to publish it, yet it always has the same result - I can see the excel process running in the background. The only way it stops, is if I close the application from the Exit button which I made containing only Environment.Exit(0);. Does anyone know a reliable way to close the excel process after code execution?

  • You must quit Excel *and* call `GC.Collect`. Also double check that Excel actually quits instead of stopping on a prompt such as "Do you want to save this". – GSerg Feb 04 '22 at 17:22
  • I've used the false parameter when Closing the workbook and also Garbage collection after quitting. I've also been told that Garbage collection shouldn't been done in same method, however that also hasn't worked. Thank you for taking the time to try to answer my question! – featUrrE Feb 04 '22 at 17:28

0 Answers0