COM interop - disposing COM objects

  • Thread starter Thread starter C# beginner
  • Start date Start date
C

C# beginner

Hi folks,
When we instantiate COM objects from our .NET code and use
them, when we no longer need the COM objects do we have to
dispose of them explicitly? If so, how?
or do the COM objects also go out of scope and get picked
up by the garbage collector? Thanks a lot for your replies.
 
When we instantiate COM objects from our .NET code and use
them, when we no longer need the COM objects do we have to
dispose of them explicitly? If so, how?

The garbage collector will handle the cleanup eventually, yes. You can
use Marshal.ReleaseComObject if you don't want to wait for the GC.



Mattias
 
Back
Top