DotNet Array

G8torG8tor Member Posts: 29
edited 2014-03-19 in NAV Three Tier
Hello

I have an external dll component that has a function that takes array of another dotnet object as a parameter.
The function is something like this: sendCustomer(Customer[]).

How can I create .net array that contains custom object. I read at http://vjeko.com/blog/generics-in-net-interop-for-nav-2013 that you could use array like this:

Arr := Arr.CreateInstance(GETDOTNETTYPE(Type),2);
Arr.SetValue(GETDOTNETTYPE(String),0);
Arr.SetValue(GETDOTNETTYPE(Int),1);

This is not working for me because im using custom DotNet object and the error message I get is that the dotnet array is not initialized.
Does anyone have any solution for me or any example of how to use dotnet array?

Cheers

Comments

  • jwilderjwilder Member Posts: 263
    Did you ever figure this out? I have the same problem.
  • lubostlubost Member Posts: 623
    System.Collections.ArrayList.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
  • jwilderjwilder Member Posts: 263
    Actually what I am looking for is a params String[]. In C# you can simply do somethinglike this:
    "<Parameter 1>", "<Parameter 2>"
    But in NAV it is expecting one dotnet paramter of params String[].

    Any thoughts?
  • xStepaxStepa Member Posts: 106
    Hi, try to use DotNET variable Array and try something like this:
    ParamsArr := ParamsArr.CreateInstance(GETDOTNETTYPE(Param1), 2);
    ParamsArr.SetValue(Param1, 0);
    ParamsArr.SetValue(Param2, 1);
    

    But I also can't get thru it in more complex functions with overloading a nullable params - like BouncyCastleCert[] chain ...
    Regards
    xStepa
  • jwilderjwilder Member Posts: 263
    This is not working, here is what I have for variables:
    ParamsArr DotNet System.Array.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    Param1 DotNet System.String.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    Param2 DotNet System.String.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

    I don't think this addresses the params keyword needed to allow this to not error during runtime. By the way it is the typical not so helpful error when parameters do not match that I get when I run my code:
    bbbe0803tqw8.png
Sign In or Register to comment.