Hi Guys,
Iam using a managed dll in my unmanaged MFC application to use ADO.NET
classes. so i have a class in the manged dll declared as follows :
class __declspec ( dllexport ) CADOInterface {
public:
////////////
//----
//////////////
int GetCacheRecordIndex(int recordId);
public:
///---
/// other declarations
///
gcroot<DataTable*> m_pDataTable;
};
In one of the method implementation, i have used a local DataRowCollection
class.
Since the CADOInterface is created in the unmanaged appllication, do i need
to use the gcroot template class with the local DataRowCollection class??? if
don't use with gcroot class, is there any memory leak???
int CADOInterface ::GetCacheRecordIndex(int recordId)
{
/// assume m_pDataTable table has some rows
gcroot<DataRowCollection*> rows = m_pDataTable->Rows;
if(rows) {
gcroot<DataRow*> row;
int recId;
for(int i=0; i < rows->Count; i++) {
row = rows->Item[i];
recId = *dynamic_cast<__box Int32*>(row->get_Item(S"RecordId"));
if(recId == recordId) return i;
}
}
return 0;
}
Also do i need to always use gcroot template class with managed classes,
when iam using in a unmanaged class??
Hari