Office automation cleanup (Excel)

  • Thread starter Thread starter Stephen Brooker
  • Start date Start date
S

Stephen Brooker

Hi all,

Just playing around a MS how-to sample to work with an Excel file from
within C#. Everything is fine and I understand it OK, however when Excel
and the application are closed, there is still an Excel process showing
up in the task manager. Every time the app is run, another process shows
up for Excel and always stays there. The only way to get rid of it is to
kill it manually.

So my question is, what is the correct way of cleaning up after
launching Excel from a C# app? Closing Excel and quitting the
application is obviously not enough.
 
Check this knowledge base article.

Office application does not quit after automation from Visual Studio
..NET client
http://support.microsoft.com/default.aspx?scid=kb;en-us;317109

When you run the code in this article, the Excel is removed from
memory, just as the article predicts.

When I added one line with the SaveAs command, it failed to be
removed from memory. My project involving Excel automation always left
Excel in memory. I never could solve it.

If you get a solution, please post it.

There is also a "microsoft.public.dotnet.framework.interop" group that
may have more help.


Paul Sullivan
 
Paul said:
Check this knowledge base article.

Office application does not quit after automation from Visual Studio
.NET client
http://support.microsoft.com/default.aspx?scid=kb;en-us;317109

When you run the code in this article, the Excel is removed from
memory, just as the article predicts.

When I added one line with the SaveAs command, it failed to be
removed from memory. My project involving Excel automation always left
Excel in memory. I never could solve it.

If you get a solution, please post it.

There is also a "microsoft.public.dotnet.framework.interop" group that
may have more help.


Paul Sullivan

Cool thanks Paul. I'll do some more research and see what I can come up
with. Let you know if it's anything brilliant. ;-)
 
FYI: It may help to know that a better version of Excel suited for interop
is located in the Microsoft Office Web Components. This instance releases
resources cleanly and is well behaved for both server and windows forms
applications.

--
Regards,
Alvin Bruney [Microsoft MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://www.lulu.com/owc
 
Back
Top