Finalize

L

Lou

Why wouldn't the Finalize method of a class not get called when the class is
destroyed?

I have a Com class that gets created from a VB6 client.
In the VB6 client code I destroy the .NET Com componenet.
Set Bla=Nothing

When I trap in the .NET code the "Finalize" method never gets called?

-Lou
 
C

Cor Ligthert[MVP]

Hi,.

As you never should do, therefore it is called managed code, that part is
done for you at the best time for it.

Cor
 
P

Patrice

I'm not that surprised. IMO Set bla=nothing just set the COM pointer to
null. This IMO doesn't make any call to the .NET side that have no idea a
pointer held by an external application has been destroyed.

IMO you should explicitely call the dispose method first...
 
L

Lou

There is no dispose method for a .NET COM class?
if so where is it and how do I call it?

-Lou
 
M

Mattias Sjögren

There is no dispose method for a .NET COM class?
if so where is it and how do I call it?

If you want a Dispose method you have to add it yourself.


Mattias
 
P

Patrice

You have to implement this in your .NET class. Try :
http://msdn2.microsoft.com/en-us/library/b1yfkh5e(vs.71).aspx
(Implemeting Finalize and Dispose to Clean Up Unmanaged Resources)

For now my understanding is that you would like to free unmanaged resources
used in a .NET class that is exposed throught COM to a VB6 application.

I saw in another thread that you have a crash in your application. If it
still doesn't work, you may want to post on the exact problem...
 

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