Office automation cleanup (Excel)

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.
 
P

Paul Sullivan

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
 
S

Stephen Brooker

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. ;-)
 
A

Alvin Bruney [MVP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top