T
techie
I have a VC++ client that creates a COM object that is implemented in C#.
The problem is the COM object doesn't get released, so I get a memory leak.
I have no problems creating the COM object and getting a pointer to the
required interface (IATImportFilter) in the client:
COleDispatchDriver* resultInterface = new COleDispatchDriver;
if ( resultInterface == NULL ) return FALSE;
COleException oOleException;
BOOL success = resultInterface->CreateDispatch( progID, &oOleException );
IUnknown *p;
if ( resultInterface->m_lpDispatch->QueryInterface( *pRequiredInterface,
(void**)&p ) != S_OK )
where prodID ("SI.ValidatorImport") is the name of COM object.
My C# COM object class is declared like this:
[ClassInterface(ClassInterfaceType.None)]
[ProgId("SI.ValidatorImport")]
public class ValidatorImport : IATImportFilter
{
The object is being released in the client like this:
((IUnknown*) pIF)->Release();
pIF = NULL;
The call to Release() on the interface does not actually destroy the object.
It doesn't call the destructor of my COM object. I tried putting a
breakpoint in there and even added a MessageBox() call but the program just
doesn't go in there.
Not sure why this happening. Since every interface supports IUnkown,
Release() should release the COM object. The COM object is only created
once.
I'm new to C# so I would appreciate some help.
The problem is the COM object doesn't get released, so I get a memory leak.
I have no problems creating the COM object and getting a pointer to the
required interface (IATImportFilter) in the client:
COleDispatchDriver* resultInterface = new COleDispatchDriver;
if ( resultInterface == NULL ) return FALSE;
COleException oOleException;
BOOL success = resultInterface->CreateDispatch( progID, &oOleException );
IUnknown *p;
if ( resultInterface->m_lpDispatch->QueryInterface( *pRequiredInterface,
(void**)&p ) != S_OK )
where prodID ("SI.ValidatorImport") is the name of COM object.
My C# COM object class is declared like this:
[ClassInterface(ClassInterfaceType.None)]
[ProgId("SI.ValidatorImport")]
public class ValidatorImport : IATImportFilter
{
The object is being released in the client like this:
((IUnknown*) pIF)->Release();
pIF = NULL;
The call to Release() on the interface does not actually destroy the object.
It doesn't call the destructor of my COM object. I tried putting a
breakpoint in there and even added a MessageBox() call but the program just
doesn't go in there.
Not sure why this happening. Since every interface supports IUnkown,
Release() should release the COM object. The COM object is only created
once.
I'm new to C# so I would appreciate some help.