Hi Folks,
This quandary should be fairly straight forward but I have yet to find an example that works. Essentially I have a struct, I create an array of these structs in C#, pass the array to C++, do some manipulation on the C++ side and return the results to C#. Everything works fine until I try to pass the data back.
My DLL import looks like this
[DllImport(DLL_LOC, EntryPoint = "_request_advanced_search@76")]
private static extern void request_advanced_search(
ref Int32 iDataSize,
ref TrackRecord [] recordBlock,
AdvancedSearch searchCriteria);
And the function on the C++ side looks like this
FUNCTION void __stdcall request_advanced_search(int & iDataSize,TrackRecord *recordBlock[],AdvancedSearch searchCriteria)
{
TrackRecord * passedRecords = new TrackRecord[iDataSize];
passedRecords = *recordBlock;
AdvancedFilters * advFilt = new FilterByDate(...);
advFilt->run_filter(&searchCriteria,passedRecords,iDataSize);
}
What I want to do is return the records that satisfy some search criteria. Since I know the number of results in my query I've tried using an IntPtr and traversing what I thought should be the resultant array. Since I'm passing by reference I've tried to reassign the passed array with the search results, but that too fails. I've tried returning the array but I get the error "Cannot marshal 'return value': Invalid managed/unmanaged type combination".
Can anyone provide some insight/code to help solve this problem?
Thanks in advance,
Scott