I have a managed class that uses a COM that looks like this.
Public Class MyClass
Private myobj as SomeComObject
Public Sub New()
myobj = CreateObject("SomeComObject.Class")
End Sub
Public Sub DoSomething()
dim innerobj as SomComObject.InnerClass
innerobj = myobj.CreateInnerClass("arg1", true, 5)
innerobj.DoSomething()
End Sub
End Class
Since I am using an unmanaged dll through a COM-Interob dll I am wondering if I need free the innerobj manually or if the gc is smart enough to do it automagically if I call ReleaseObject()
My class implements IDisposable and I do the following atm:
Runtime.InteropServices.Marshal.ReleaseComObject(myobj)
Do I need to take care of releasing all inner objects that are created by the COM Object or not? And If I do have to do it, does the order matter (first inner then parent vs parent then inner)?