Automation ArrayList in NAV 2013 R2

navuser1navuser1 Member Posts: 1,329
edited 2015-08-18 in NAV Three Tier
Dear All,

How do I read the ArrayList of a custom dll in NAV 2013 R2 Environment ?

Please reply.
Now or Never

Comments

  • massimopasqualimassimopasquali Member Posts: 82
    Look that :

    Name DataType Subtype Length
    NETArray DotNet System.Array.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    NETTYpe DotNet System.Type.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    NETConvert DotNet System.Convert.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

    NETBufferLocal := NETBufferLocal.GetType('System.Buffer',FALSE);
    NETTYpeLocal := NETTYpeLocal.GetType('System.Byte',FALSE);
    NETArrayLocal := NETArrayLocal.CreateInstance(NETTYpeLocal, XMLText.LENGTH);
    NETArrayLocal := Encoding.UTF8.GetBytes(XMLText);
    MemoryStreamLocal := MemoryStream.MemoryStream(NETArrayLocal);
    MemoryStreamLocal.Flush();
    MemoryStreamLocal.Position := 0;
  • navuser1navuser1 Member Posts: 1,329
    Look that :

    Name DataType Subtype Length
    NETArray DotNet System.Array.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    NETTYpe DotNet System.Type.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    NETConvert DotNet System.Convert.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

    NETBufferLocal := NETBufferLocal.GetType('System.Buffer',FALSE);
    NETTYpeLocal := NETTYpeLocal.GetType('System.Byte',FALSE);
    NETArrayLocal := NETArrayLocal.CreateInstance(NETTYpeLocal, XMLText.LENGTH);
    NETArrayLocal := Encoding.UTF8.GetBytes(XMLText);
    MemoryStreamLocal := MemoryStream.MemoryStream(NETArrayLocal);
    MemoryStreamLocal.Flush();
    MemoryStreamLocal.Position := 0;


    Could you be more clear.

    My variable are :
    Name DataType Subtype Length
    csc Automation 'CSClb'.Class1

    csc.ReadCardDetails ==>> ArrayList
    Now or Never
  • massimopasqualimassimopasquali Member Posts: 82
    Hi, sorry I have seen your replay now.

    It's easy:

    In my case, I had did to implement an array of byte, becouse I had had the necessity to send a file XML from NAV to NAV by a DLL C# .NET. In C# .NET I will writing this sentence :

    byte[] readBuffer = new byte[4096];

    to that in NAV you have to define in development environment this type of global variables.

    Name DataType Subtype Length
    NETArray DotNet System.Array.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    NETTYpe DotNet System.Type.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    NETConvert DotNet System.Convert.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

    NETArray : Is a .NET namspace "System", in our case we have necessity of a subsidiary namespace "Array", so you make, in NAV, a
    global variable "DotNet" finding "System.Array.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

    NETTYpe : Is a .NET namspace "System", in our case we have necessity of a subsidiary namespace "Type"; you have necessity of this variable becouse when you will instance the array you must specify the type of array : byte (in my case), string, ecc

    NETConvert : In my case I made a conversation from "Stream" to "String"

    Well, now you can create your array, in the manner :

    1) Define the type of array, in my case was of byte
    NETTYpeLocal := NETTYpeLocal.GetType('System.Byte',FALSE);
    2) Instancing the array specifying the type of arrya trought the variable "NETTYpeLocal" and specifying the lenght of array.
    NETArrayLocal := NETArrayLocal.CreateInstance(NETTYpeLocal, XMLText.LENGTH);

    Now you can use that, I convert my XML text in byte putting them in my array
    NETArrayLocal := Encoding.UTF8.GetBytes(XMLText);

    bye!! :-)
Sign In or Register to comment.