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?