Problem with unmanaged pointer in managed c++
Hello all from a newby!
I have a class written in unmanaged c++ that does exactly as i want it
to. I have a corresponding wrapper class in managed c++, and testing it
elsewhere within the managed code, the wrapper classes seem to function
correctly. However, when i create one of these classes in c#, i can use
the functions etc, but it blows up later on when it hits the delete
inside the finalize and gives me the following "Unhandled exception at
0x03c2aa13 in RD.exe: 0xC0000005: Access violation reading location
0xcdcdcdcd." Any ideas what could be causing this? The back end seems
to work properly, and the wrapper class seems to work also, but as soon
as it's brought into c#, it blows up!
using namespace RD::Utils_win;
/// <summary>Constructor</summary>
Category::Category(RD::Utils::Category* pCategory) :
m_pCategory(pCategory)
{
}
/// <summary>Constructor</summary>
Category::Category() :
m_pCategory(new RD::Utils::Category())
{
}
/// <summary>Destructor.</summary>
Category::~Category()
{
delete m_pCategory;
m_pCategory = NULL;
}
/// <summary>Finalize.</summary>
Category::!Category()
{
delete m_pCategory;
m_pCategory = NULL;
}