all groups > dotnet interop > july 2004 >
You're in the

dotnet interop

group:

COM Object Lifetime when called from VB.NET


COM Object Lifetime when called from VB.NET Greg Doherty
7/27/2004 12:02:28 PM
dotnet interop:
Hi,

I have a C++ COM class that I instantiate from VB.NET, but the object never
gets released. Is there something that I need to do to force the
destruction of the object?

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim Importer As MyLibrary.Import = New MyLibrary.Import
...
Importer = Nothing
End Sub

The COM class (MyLibrary.Import) is instantiated and everything works fine,
but when the VB.NET function exits, the object is never destroyed (neither
FinalRelease() or the destructor ever get called).

Is there something that I am missing?

Thanks,
- Greg

Re: COM Object Lifetime when called from VB.NET Brian Muth
7/27/2004 12:11:20 PM
[quoted text, click to view]

Marshal.ReleaseComObject()

Brian

Re: COM Object Lifetime when called from VB.NET Greg Doherty
7/27/2004 12:32:24 PM
Brilliant!

Thanks,
- Greg

[quoted text, click to view]

AddThis Social Bookmark Button