I have a managed c++ function below that makes a call to an unmanaged c++ dll
.. This function is called from a C# app, resulting in a
"Debug Assertion Failed dbgdel.cpp Line 52
Expression: _BLOCK_TYPE_IS_ VALID(pHead->nBlockUse)" errir message.
This happens on function exit, looks like related to destruction of some vector.
Any ideas why ????
ArrayList*
NM::doSomething (ArrayList* anchorStrikesLi st,
ArrayList* anchorVolsList,
ArrayList* allStrikesList
{
vector<double> anchorStrikesVe c, anchorVolsVec, allStrikesVec, allVolsVec;
////// convert to vectors ////
for (int i = 0; i < anchorStrikesLi st->Count; ++i)
{
double val = *dynamic_cast<d ouble __gc *>(anchorStrike sList->get_Item(i)) ;
anchorStrikesVe c.push_back(val );
}
for (i = 0; i < anchorVolsList->Count; ++i)
{
double val = *dynamic_cast<d ouble __gc *>(anchorVolsLi st->get_Item(i)) ;
anchorVolsVec.p ush_back(val);
}
for (i = 0; i < allStrikesList->Count; ++i)
{
double val = *dynamic_cast<d ouble __gc *>(allStrikesLi st->get_Item(i)) ;
allStrikesVec.p ush_back(val);
}
// unmanaged c++ dll call
foo(anchorStrik esVec, anchorVolsVec, allStrikesVec, allVolsVec);
// Convert back to vector of computed vols and return
ArrayList* allVolsList = new ArrayList();
for (i = 0; i < allVolsVec.size (); ++i)
{
double vol = allVolsVec[i];
allVolsList->Add(__box(vol) );
}
return allVolsList;
}
.. This function is called from a C# app, resulting in a
"Debug Assertion Failed dbgdel.cpp Line 52
Expression: _BLOCK_TYPE_IS_ VALID(pHead->nBlockUse)" errir message.
This happens on function exit, looks like related to destruction of some vector.
Any ideas why ????
ArrayList*
NM::doSomething (ArrayList* anchorStrikesLi st,
ArrayList* anchorVolsList,
ArrayList* allStrikesList
{
vector<double> anchorStrikesVe c, anchorVolsVec, allStrikesVec, allVolsVec;
////// convert to vectors ////
for (int i = 0; i < anchorStrikesLi st->Count; ++i)
{
double val = *dynamic_cast<d ouble __gc *>(anchorStrike sList->get_Item(i)) ;
anchorStrikesVe c.push_back(val );
}
for (i = 0; i < anchorVolsList->Count; ++i)
{
double val = *dynamic_cast<d ouble __gc *>(anchorVolsLi st->get_Item(i)) ;
anchorVolsVec.p ush_back(val);
}
for (i = 0; i < allStrikesList->Count; ++i)
{
double val = *dynamic_cast<d ouble __gc *>(allStrikesLi st->get_Item(i)) ;
allStrikesVec.p ush_back(val);
}
// unmanaged c++ dll call
foo(anchorStrik esVec, anchorVolsVec, allStrikesVec, allVolsVec);
// Convert back to vector of computed vols and return
ArrayList* allVolsList = new ArrayList();
for (i = 0; i < allVolsVec.size (); ++i)
{
double vol = allVolsVec[i];
allVolsList->Add(__box(vol) );
}
return allVolsList;
}
Comment