[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

C# Finalize not called by CCW - really true?

czapkofan

7/20/2007 12:46:00 PM

Is that really true that in an in-proc C# assembly the Finalize
methods are not called when COM objects are destroyed from the caller?
And if so, is there any solution for this problem? Or the only one is
to define a "Cleanup()" method and tell all users to call it and hope
they will?

I'm using .NET 2.0 and the C# DLL is called from a .vbs file (WSH)
(and it's called with a help of a DLL Surrogate, because I want it to
be available via DCOM)

1 Answer

Sheng Jiang

7/20/2007 6:17:00 PM

0

I am calling Marshal.ReleaseComObject every time finished using a com object
from a method call, usually in a finally block to avoid leaking COM objects
when an exception is thrown.

--
Sheng Jiang
Microsoft MVP in VC++
<czapkofan@gmail.com> wrote in message
news:1184935575.408346.310420@k79g2000hse.googlegroups.com...
> Is that really true that in an in-proc C# assembly the Finalize
> methods are not called when COM objects are destroyed from the caller?
> And if so, is there any solution for this problem? Or the only one is
> to define a "Cleanup()" method and tell all users to call it and hope
> they will?
>
> I'm using .NET 2.0 and the C# DLL is called from a .vbs file (WSH)
> (and it's called with a help of a DLL Surrogate, because I want it to
> be available via DCOM)
>