.NET Component called from COM Component not released

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



We have a test environment in which we instantiate a COM/ATL/C++ component
from a Managed/Console/.NET/C# application. The COM component in turn
instantiates and calls a .NET/C#/Class Library component using Interop as
below:

#import "demologger.tlb" raw_interfaces_only named_guids no_namespace
// log using .NET Interop
CComPtr<IDemoLogger> pILogger;
bstr_t bstrMessage = "Hello from COM to .NET";

hResult = pILogger.CoCreateInstance ( CLSID_DemoLogger,
NULL,
CLSCTX_SERVER );
if ( 0 == hResult ) pILogger->LogToFile ( bstrMessage );
else return S_FALSE;

// We are done
pILogger = NULL;

Even if this logic and the CComPtr go out of scope and the reference count
is decremented, neither the destructor or the Dispose methods of the .NET
component are called. How can we ensure/enforce disposal or components used
via Interop?

Flow is:

Console/.NET ---> COM/ATL component ---> .NET Component
.



Relevant Pages

  • Re: .NET Component called from COM Component not released
    ... You won't get Dispose called - who's going to call it? ... > // log using .NET Interop ... neither the destructor or the Dispose methods of the .NET ...
    (microsoft.public.dotnet.framework.interop)
  • Re: .NET Component called from COM Component not released
    ... > // log using .NET Interop ... > pILogger = NULL; ... neither the destructor or the Dispose methods of the .NET ...
    (microsoft.public.dotnet.framework.interop)
  • Re: COM Componente/ COM Objekt unter C# erstellen ?
    ... ist die Funktionen dieser Komponente später in Visual Basic Script zu nutzen. ... [.NET Interop: Get Ready for Microsoft .NET by Using Wrappers to Interact with COM-based Applications] ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • Re: AzMan Access Check
    ... ..Net2.0 to interop the AzMan APIs. ... domain password, and path to my user account LDAP path, it still fails. ... AzMan API or .Net interop side. ...
    (microsoft.public.platformsdk.security)