I have to find the way to build the array of structs on C++ Win32 side. I don\'t have the initial number of items. It should be very fast to resize that array.
When
Generally if your C++ dll compiled with CLI support you can simply use managed containers. If you don't want your dll to be compiled with CLI option, then you may write small C++/CLI wrapper dll which will call methods from native C++ dll and store objects in the managed container. Another possible solution is to change interface of the C++ lib to return objects by indexes, support insertion and/or removal.
std::vector vec;
void init() {
//read data to vec
}
CFoo getIthElement(int i) {
return vec[i];
}
int getElementCount() {
return vec.size();
}
So you will use getIthElement
and getElementCount
functions on the C# side.