I have a ASP.net application on IIS. In this app I created a Excel application:
using Excel = Microsoft.Office.Interop.Excel;
public Excel.Application ExlApp;
//
public Excel.Workbook ExlWb;
//
public Excel.Worksheet ExlWs;
During the application work, I created a new workbooks and in finally, I destroy my objects:
GC.Collect();
GC.WaitForPendingFinalizers();
Marshal.ReleaseComObject(ExlWs);
ExlWb.Close(Type.Missing, Type.Missing, Type.Missing);
Marshal.ReleaseComObject(ExlWb);
The problem: during the work, the EXCEL proces is growing up in memory, how can I close the workbooks correct?
Maybe you should look at replacing the Excel automation with OpenXML processing. Automating office applications server side is an unsupported scenario:
http://support.microsoft.com/kb/257757
"Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment."