"Dimensions" are fixed on Array's in NAV, which makes it difficult to accept and send array-based data from COM.
While I haven't had the same issue, I've had the opposite (passing an array of strings to a COM), and one of the easiest ways was to use a loop and function to send the strings into a COM/DLL one at a time, then signal complete with a flag or similar. An unbounded array would be useful in .NET as you can just keep adding the strings as needed. I'm going to assume the DLL is .NET based;
So from .NET to C/AL;
- A flag or function to let C/AL know that the array loop has finished
- C/AL can use a loop to fetch each 'element' until the flag is set
- .NET will need to feed the array items one by one
So from C/AL to .NET;
Similar to .NET to C/AL except .NET has unbounded arrays which makes things a little easier.
DotNetArray.ClearArray;
REPEAT
DotNetArray.Add(Customer.Name);
UNTIL
DotNetArray.EndOfArray;
Things to note;
- Array indexes in C/AL are 1-based, .NET is 0 based.
- An alternate way would be to pass the count and loop for x times
The following article might also be useful; http://dynamicsuser.net/blogs/waldo/archive/2011/03/21/nav-2009-r2-net-interop-using-arrays-collections.aspx