Free .NET objects from VB6 code

On .NET Rocks! Show 561 , Carl and Richard talked about the release of unmanaged objects created in managed code. If you need to release a COM object created in .NET managed code, you must call System.Runtime.InteropServices.Marshall.ReleaseComObject. Is there something similar that you should do (or should do) when releasing .NET objects from COM code, or is it enough to rely on the garbage collector to release objects?

+3
source share
2 answers

As long as you control the COM counter Callable Wrapper , like any other COM object ( set netObj = Nothing) COM and .NET will take care of everything else.

+4

, VB6, DotNet, . :.

class SomeEventClass
{
    public event EventHandler SomeEvent;

    public void DoSomething()
    {
        var someEvent = SomeEvent;
        if (someEvent != null)
        {
             someEvent(this, new EventHandlerArgs());
        }
    }

    public void ReleaseFromEvents()
    {
         SomeEvent = null;
    }

}

, , VB6 . - ...

+3

Source: https://habr.com/ru/post/1750732/


All Articles