1

I have written a winform app that outputs to an Excel file. I am failing to properly clean up afterwards, however, since I always end up with way too many Excel processes running. Here is the creation and destruction code:

Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
Workbook wb = xlApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
Worksheet ws = (Worksheet)wb.Worksheets[1];
...
wb.Close();
xlApp.Quit();

Can someone tell me what I am missing?

Regards.

Kevin
  • 1,252
  • 6
  • 32
  • 50
  • Have you take a look at [this](http://stackoverflow.com/questions/5513319/c-sharp-why-are-excel-processes-not-ending)? – Ross Jun 29 '12 at 14:11
  • Also this: http://stackoverflow.com/questions/158706/how-to-properly-clean-up-excel-interop-objects-in-c-sharp – Dan Jun 29 '12 at 14:15
  • Thanks. I did read those posts before I asked. I don't seem to have "Marshal" as an option. I am using Microsoft.Office.Interop.Excel. Do I need to include another library? – Kevin Jun 29 '12 at 15:21

0 Answers0