How to kill COM object in .NET

  • Thread starter Thread starter Li Pang
  • Start date Start date
Li Pang said:
Using the following codes:
GC.Collect()
GC.WaitForPendingFinalizers()

This will work, but you should know that it freezes all the threads in your
process for the duration of the GC.Collect(). So you should be very careful
in running this in a multi-threaded environment such as COM+ or ASP.NET.

System.Runtime.InteropServices.Marshal.ReleaseComObject(App)

is probably all you need. This decrements the ref count on the COM object
to 0, and invokes any destructors on the object.

David
 
Back
Top