Welcome! and rules
Joel on Software
Excel object persisting
The Excel object that i created in my ASP.Net application is not get destroyed even after session is closed.In the code i have tried methods like .Quit,Marshal.ReleaseComObject etc to kill the object still it pesists.....Help
Probably waiting for garbage collection. Why is this important? Does the object block any resources?
If you are done with the objects, you can force garbage collection and you shouldn't have any problems. We had to do this with a .NET component we use that calls into a COM object because until it was garbage collected, it would hold onto a connection. Since we sell our appliction by number of connections, customers were understandably upset by this, so in all of our top level calls, when we are done with the underlying objects, we force garbage collection to clean the connections up.
Tyr explicitly setting each level of the Excel object to nothing. I found that (in windows programming) if I used a Worksheet object I had to make sure I did Worksheet = Nothing, Workbook = Nothing and Application = Nothing. If you're declaring a worksheet without explicitly declaring a workbook try breaking out all that code and setting each to nothing.
Like zig zag noted, you have to release all the explicitly and implicitly created objects. Here is a sample code..this is a slightly modified version of code sample from MS KB Article.
Fog Creek Home