Howard Bartfield wrote:

> however, I'm just concerned to find out why the Garbage Collection doesn't
> work in the first example, but does in the second.

Probably because it implements a Finalize. You'll need to collect twice to
actually get the object cleaned. Objects with finalization require two
passes through to get cleaned up (which is why you should always, always
provide Dispose and then suppress finalization for an object that has been
disposed). Of course, MS didn't follow their own guidelines, and should've
implemented Dispose on their COM wrappers. :-p

Of course, you should use Marshal.ReleaseComObject() in all cases, because
forcefully causing a garbage collection (even once, not to mention twice) to
get your COM object cleaned up is akin to sledge hammering an egg. :)

Brad

--
Read my web log at http://www.quality.nu/dotnetguy/

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to