Thursday, January 20, 2005

The Code Project - Release Excel Object - VB.NET

The Code Project - Release Excel Object - VB.NET

"Nearly every developer have encountered one day what I encountered while dealing
with com object and the pain in releasing it from memory.

in the following example, I will describe my experience in how I solved an issue with Excel object, and the way I followed to kill those hanging objects where I tried many known methods and none worked."


Seems like .NET <-> COM/Excel is fun for everyone... I ran into this early last year too and posted about it here, VS2003 & Excel "Leaking..." and Forcing Garbage Collection and here, How to fully close Excel when using COM Interop (addm: VS2003 & Excel "Leaking..." and Forcing Garbage Collection)

It's easy to go overboard when trying to deal with this. Also given how common this issues seems to be, I would think MS could provide official guidance, pattern, etc.

Yeah, once you figure it out, it's not hard to handle, but think about the man hours being wasted on this one issue. If I've run across three pretty much by accident, then how many other people have run into then then solved this? Hundreds? Thousands? Now add in the people making manged Outlook addin's and their "fun" with ReleaseCOMObject...

There must be a easier, less error prone and more "standard" way to work with COM objects from .NET. The PIA's seem to help, but only if you're using Office XP/2K3. And yeah, one day we'll live in a Managed world. But that's many years yet...

No comments: