By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,573 Members | 1,760 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,573 IT Pros & Developers. It's quick & easy.

How to kill COM object in .NET

P: n/a
Using the following codes:
GC.Collect()
GC.WaitForPendingFinalizers()

-----Original Message-----
Hi,

I used following codes in vbscript and VB6 to create/kill
COM object, and it works successfully.

Dim App
Set App = CreateObject("App")
Set App = Nothing

The equivalent codes in .NET are:

Dim App
App = CreateObject("App")
App = Nothing

However, at last line, the instance of App could not be
removed, any body can help me?

Thanks

.

Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"Li Pang" <li*****@eu.altria.com> wrote in message
news:08****************************@phx.gbl...
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.ReleaseComO bject(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
Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.