Domanda

As part of our software business, we offer a development kit for developers to integrate our software into theirs. We generally try to cater to many different languages/environments.

Recently, we've been getting some inquiries from some potential clients who are using Microsoft's Dynamics NAV. One of the flavors of our SDK is a COM callable dll, which can be referenced in NAV.

Now, one of the methods in our API returns a String array. One of the developers we're running a pilot program with reported problems using that method, and he couldn't find a way around it. We had to give him a workaround method which just returns the first index of the array (which is enough for his specific purposes), but this is obviously not a solution.

Unfortunately, we have zero Navision experience on hand, nor do we have a licensed copy of Navision (the trial version doesn't seem to let you tinker with code) and I wasn't able to find any information on this anywhere online.

Does anyone know if this is possible? And if so, what is the correct way to do it?

È stato utile?

Soluzione

"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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top