Finalize

  • Thread starter Thread starter Lou
  • Start date Start date
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
 
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
 
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...
 
There is no dispose method for a .NET COM class?
if so where is it and how do I call it?

-Lou
 
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
 
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...
 
Back
Top