LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dot NET Assembly and Labview Arrays

I have come across a similar issue as discussed here:

https://stackoverflow.com/questions/42136239/interop-class-wants-arrays-of-type

When loaded into visual studio generated .NET assembly is wanting a double[*] which apparently means a non-zero based indexed "array" as opposed to a double[] "vector". The solution using Array.CreateInstance() works, but then results in a clunky datatype to work with, compared to just working with double[] vectors.

 

Does anyone have a good method for working through this issue? The following note doesn't seem to apply to VS 2017 Community, as I tried implementing it, but still produced the type mismatch.

http://digital.ni.com/public.nsf/allkb/C4D7D4F0F33098CC86257F46005D52F2

0 Kudos
Message 1 of 7
(3,210 Views)

Hi raceybe,

 

What version of LabVIEW are you using to build your assembly?

 

Could you give us some insight into how you build the array in LabVIEW?

 

Thanks,

Mitchell | NI

0 Kudos
Message 2 of 7
(3,125 Views)

This was Labview 2017 64 bit.

 

I'll need to build the file again, but It was pretty standard. I built a wrapper around a mathscript node, to implement the linspace() function. There were two doubles and an int32 as inputs (those showed up fine in Visual Studio) and the result was a double array (which showed up as a double[*] instead of double[]).

 

If you need more than that for recreating it, I can do so, and probably will after I post this.

0 Kudos
Message 3 of 7
(3,122 Views)

I just noticed that the result is actually expected based on what the Define VI Prototype dialog reports (attached). It reports that the array is of type "Array" which is what requires the work around I outlined in the original post (Array.CreateInstance()). I've also attached the snipped for the image below.

 

 

image.png

0 Kudos
Message 4 of 7
(3,118 Views)

Have you tried the 2-dimensional array workaround mentioned in the knowledge base article you linked in your first post?

 

What was the result?

0 Kudos
Message 5 of 7
(3,098 Views)

I did try it, the result was the same. Still an Array type, rather than double[] or double[][]. Snippet of example attached. Screenshot of out Array also shown inline.

 

I need to correct myself it appears, though I haven't given it a full workup yet. Using the 2D array output is reported as a double[,] which I think is what is desired. I'll go a bit more in depth to make sure. It could be that when I first tried it, I didn't modify the function prototype after I switched the output to 2D and as a result, I still saw double[*].

 

I'll try to validate it a little more care and post here again.

 

image.png

 

 

0 Kudos
Message 6 of 7
(3,095 Views)

This issue is (probably) fixed in LabVIEW 2017 SP1, refer to this NI article.

0 Kudos
Message 7 of 7
(2,284 Views)