.NET application does not release Excel

  • Thread starter Thread starter Cameron Eckman
  • Start date Start date
C

Cameron Eckman

Let me prefix with, I've done many VB6 and ASP applications that read
from/write to Excel and have never had a problem. I'm not a beginner at
this...

I have created my first .NET Windows application that reads from Excel 2000
and writes to a tab file. I am using the code below and when stepping
through the appExcel.Quit() is executed. However, the EXCEL.EXE process
still runs and will run until I close the .NET application I've built. This
happens in both DEBUG and RELEASE compilations.

Try
appExcel = New Excel.Application()
... coding tasks ...

Catch ex As Exception
... error tasks ...

Finally
appExcel.Quit()

Any ideas why Excel is not being released after the quit? I even tried
adding GC.Collect() to see if it helps to force the Garbage Collection to
release appExcel.

Thanks, in advance.
 
Because Excel is a COM based application, I'm wondering if you don't need to
manually destroy the Excel object reference like in the COM world:

Finally
appExcel.Quit()
appExcel = Nothing
End Try
 
Cameron,

* "Cameron Eckman said:
I have created my first .NET Windows application that reads from Excel 2000
and writes to a tab file. I am using the code below and when stepping
through the appExcel.Quit() is executed. However, the EXCEL.EXE process
still runs and will run until I close the .NET application I've built. This
happens in both DEBUG and RELEASE compilations.

PRB: Office Application Does Not Quit After Automation from Visual Studio .NET Client
<http://support.microsoft.com/?scid=kb;en-us;317109>
 
* "Scott M. said:
Because Excel is a COM based application, I'm wondering if you don't need to
manually destroy the Excel object reference like in the COM world:

You can remove the reference by calling 'Marshal.ReleaseComObject', but
not by setting an instance variable to 'Nothing' (in this case).
 
Back
Top