S
Steve Baer
I'm wrapping unmanaged C++ classes using the standard managed C++ approach.
i.e. a __gc class that contains an internal pointer to an unmanaged class.
The purpose is to generate a .NET class library from our unmanaged class
library.
There are static unmanaged classes in this library, so I'm following the
MSFT approach of creating static functions that call __crt_dll_initialize at
startup and __crt_dll_terminate at the end of the calling application. My
problem occurs when I call the __crt_dll_terminate function at the end of my
test application. Immediately after this function gets called, the garbage
collector cleans up wrapper classes.
WrapperClass::~WrapperClass(){
if(m_ptr) delete m_ptr; //delete internal unmanaged class
m_ptr=NULL;
}
The wrapper class finalizer throws a NullPointer exception when I attempt to
delete the internal pointer. If I remove the call to __crt_dll_terminate,
everything works fine. I guess I'm confused as to what to do about this.
Thanks for any help in advance,
-steve
i.e. a __gc class that contains an internal pointer to an unmanaged class.
The purpose is to generate a .NET class library from our unmanaged class
library.
There are static unmanaged classes in this library, so I'm following the
MSFT approach of creating static functions that call __crt_dll_initialize at
startup and __crt_dll_terminate at the end of the calling application. My
problem occurs when I call the __crt_dll_terminate function at the end of my
test application. Immediately after this function gets called, the garbage
collector cleans up wrapper classes.
WrapperClass::~WrapperClass(){
if(m_ptr) delete m_ptr; //delete internal unmanaged class
m_ptr=NULL;
}
The wrapper class finalizer throws a NullPointer exception when I attempt to
delete the internal pointer. If I remove the call to __crt_dll_terminate,
everything works fine. I guess I'm confused as to what to do about this.
Thanks for any help in advance,
-steve