How to kill COM object in .NET

  • Thread starter Thread starter Li Pang
  • Start date Start date
L

Li Pang

Using the following codes:
GC.Collect()
GC.WaitForPendingFinalizers()
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top