From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

.Net(C#) dll pass 2D Array To LabView

Hello Expert:
  I have make a dll user Microsoft Visual C# .NET .and use usercontrol inherit datagrid for add function of dropdownlist in datagrid.
 It's can load into labview front panel operate no problem.
 I translate datagrid every cell to string[][] use property  in my dll class for labview to implement.
 
In labeview block diagram use dll property GetDataFromFirstRow is alight,
but use dll property GetDataFromTable is error.
(error message:The type of the source is 1-D of 1-D array of string.The type of the sink is 2D array of string) 
 
this very trouble me,so i need help.
 
0 Kudos
Message 1 of 5
(6,180 Views)

Sorry I forget append my C# source

public string[] GetDataFromFirstRow
  {
   get
   {
    int iCol=dtData.Columns.Count;
    string[] sAr=new string[iCol];
    for(int i=0;i<iCol;i++)
    {
     sAr[i]=dtData.Rows[0][i].ToString();
    }
    return sAr;
   }

  }

  public string[][] GetDataFromTable
  {
   get
   {
    int iRow=dtData.Rows.Count;
    int iCol=dtData.Columns.Count;
    //Array sAr=new string[iRow][];
    //Array sAr=new ArrayList();
    string[][] sAr=new string[iRow][];

    for(int i=0;i<iRow;i++)
    {
     sAr[i]=new string[iCol];
     for(int j=0;j<iCol;j++)
     {
      sAr[i][j]=dtData.Rows[i][j].ToString();
     }
    }
    return sAr;
   }

0 Kudos
Message 2 of 5
(6,178 Views)
Hello,
 
I'm not sure of the problem you are having - I created the attached VI and C# source, where I built the corresonding solution in VS, and used the resulting assembly to obtain both a 1 and 2 dimensional array in the VI (MyFunction returns a 1D array, and MyFunction2 returns a 2D array).  Can you successfully do this as well?  I don't think I understand your question, but based on the title of the thread, perhaps this example of passing a 2D array of doubles from .NET to LabVIEW will help!
 
Best Regards,
 
JLS
 
PS - the assembly (dll file) could not be attached with the name/extension .dll, so I have renamed the extension to .txt - you should change the file name to .dll before opening the VI.  Also, after you rename the extension .txt file to .dll, make sure it is in the same directory as the VI.
 
 
Best,
JLS
Sixclear
Download All
Message 3 of 5
(6,157 Views)

Thank  to foresignt Veteran:
        After reveived your sample file,I understand error reason.
     Labview don't  identify  double[] []  just double[,] .
     In other word,double[,] is array type and double[][] is object type.
     I change my  double[][]  type to double[,] is alight.

                                                     Thank you very mush.

 

0 Kudos
Message 4 of 5
(6,145 Views)
Excellent!
 
Best Regards,
 
JLS
Best,
JLS
Sixclear
0 Kudos
Message 5 of 5
(6,136 Views)