Oleg
Oleg

Reputation: 1765

How can I dispose Excel COM object on IIS

I have a ASP.NET app on IIS . In this application I use Excel COM Object :

using Excel = Microsoft.Office.Interop.Excel;

I use this objects:

        public Excel.Application ExlApp;
        //
        public Excel.Workbook ExlWb;
        //
        public Excel.Worksheet ExlWs;

And destroy them like this:

        GC.Collect();
        GC.WaitForPendingFinalizers();

        Marshal.ReleaseComObject(ExlWs);



        ExlWb.Close(Type.Missing, Type.Missing, Type.Missing);
        Marshal.ReleaseComObject(ExlWb);

        ExlApp.Quit();
        Marshal.ReleaseComObject(ExlApp);

So, it works normal on Visual Studio 2008. BUT! When I start this application only on IIS, the Excel process could not be destroy! HELP!

Upvotes: 0

Views: 588

Answers (1)

eppdog
eppdog

Reputation: 423

I have had issues in the past with excel processes sticking around after calling .Quit() as well. The solution I hacked my way into was finding the running process and killing it. This may not be optimal, but I though I would share my experience.

Upvotes: 1

Related Questions