I have developed a MFC dll containing a function having this prototype:
//DLL code
long __declspec(dllexport) GetData(CString csIdentifier, CStringArray& arrOfData)
{
//based on the identifier I must add some strings inside the string array
arrOfData.Add("...");
arrOfData.Add("...");
/*.....................*/
return 1;
}
The problem that I have is after the function gets called (from the executable). The destructor of the arrData will be called and will try to release the memory but it will not succeed because the allocation of the arrOfData was done on another heap(inside the dll). Although I have compiled both applications (Exe and Dll) using the same enviroment settings, I still have the issue in both debug and both release mode. How can I solve the issue?
//Executable code
{
CStringArray arrData;
GetData("Identifier",arrData);
//data is accesible
}
heap violation occurs just before existing the code block