Force termination of COM object?

O

Oenone

I'm developing a wrapper around a series of VB6 plugins that I now want to
be able to run in my VB.NET application.

Everything is working fine, except I can't find a way to get the
Class_Terminate from the VB6 classes to fire when I've finished with the
objects.

In VB6, these obviously fire when the last reference to the object is set to
Nothing. In .NET, this doesn't happen until I close my application (or,
presumably, when the garbage collector next runs).

Is there any way that I can force the VB6 classes to terminate? Some of them
have clean-up code in their Terminate events, and without running this I'm
worried that I may end up leaving resources locked. I have a Dispose method
in my .NET wrapper class so I have a point in code at which I could trigger
the termination, but I can't find a way to make it happen.

My thanks in advance,
 
N

Nick Hall

Have a look at System.Runtime.InteropServices.Marshal.ReleaseComObject.

Hope this helps,

Nick Hall
 

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

Top