K
Kiran via .NET 247
Hi.
I have a C++ dll that exports following functions
__declspec(dllexport) voidprintStringVector(std::vector<std::string> filenamesList) {
for(int j = 0; j < filenamesList.size(); j++)
cout << filenamesList[j].data() <<endl;
}
__declspec(dllexport) void printIntVector(std::vector<int>intList){
for(int j = 0; j < intList.size(); j++)
cout << intList[j] <<endl;
}
I am trying to invoke these function from Managed C++. The'printIntVector' method is able to print the values in thevector. However, when exiting the function I get a_CrtIsValidHeapPointer Assert. On the other hand, the stringvector passed to 'printStringVector' function seems to begarbled totally. The function simply crashes when trying toprint the string data. I have ensured that the C++ dll and theMC++ exe are both linked to the multithreaded debug dlls.
Following is the MC++ code snippet:
vector <int> v1;
v1.push_back(5);
v1.push_back(12);
std::vector<std::string> filenamesList ;
filenamesList.push_back(string("hello"));
filenamesList.push_back(string("world"));
printIntVector(v1);
printStringVector(filenamesList);
Any idea what the problem is? Is it because I have not "pinned"the objects?
I have a C++ dll that exports following functions
__declspec(dllexport) voidprintStringVector(std::vector<std::string> filenamesList) {
for(int j = 0; j < filenamesList.size(); j++)
cout << filenamesList[j].data() <<endl;
}
__declspec(dllexport) void printIntVector(std::vector<int>intList){
for(int j = 0; j < intList.size(); j++)
cout << intList[j] <<endl;
}
I am trying to invoke these function from Managed C++. The'printIntVector' method is able to print the values in thevector. However, when exiting the function I get a_CrtIsValidHeapPointer Assert. On the other hand, the stringvector passed to 'printStringVector' function seems to begarbled totally. The function simply crashes when trying toprint the string data. I have ensured that the C++ dll and theMC++ exe are both linked to the multithreaded debug dlls.
Following is the MC++ code snippet:
vector <int> v1;
v1.push_back(5);
v1.push_back(12);
std::vector<std::string> filenamesList ;
filenamesList.push_back(string("hello"));
filenamesList.push_back(string("world"));
printIntVector(v1);
printStringVector(filenamesList);
Any idea what the problem is? Is it because I have not "pinned"the objects?