LabVIEW

cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 

create array of structs from a .NET DLL

I hope you can see the assembly in the context help. Than I tested the To object.vi, but it doesn't help.

Thanx Thomas

0 Kudos
Message 11 of 17
(1,464 Views)
The part that is missing in your VI is to take the output of To Object and use the To More Specific routine to convert it from a System.Object to a .NET byte[] (and by the way, a byte in .NET is a uint8 not an int8).
 
I did a little more digging and found an easy way to get the refnum you need to pass into To More Specific (see the image attached). The ToString is just for testing, so you don't need that. Just use the refnum coming out of GetType and wire that into the top of To More Specific. Then wire the output of that into your method and see if it fixes it.
0 Kudos
Message 12 of 17
(1,459 Views)

Hi Brian,

sorry, but your solution doesn't work. I tied it like in the attachment. But there is a error, Wire: class conflict. So I tried it i a other way to connect InvokeNode: System.Byte[] with Method Initialize and pass it to the input, but this didn't work. The main problem is, that there is no constructor for System.Byte[]. I can only create a Invoke Node...but in this case I have to use a method. How is it possible to create a System.Byte reference???

thx, thomas

0 Kudos
Message 13 of 17
(1,444 Views)
Argh, sorry. This is what happens when I don't sit down and do the whole thing myself. But, this time I have and I have to take something back - you can create the correct byte[] refnum from your method (at least I was able to).
 
Right-click on your ReadData input terminal for the byte[] and say "Create Constant". This will drop down the .NET refnum constant for a byte[] (and not a byte[]&). You can then pass this into the "To More Specific" and be on your way. Thus you can remove the GetType invoke, that was my bad.
0 Kudos
Message 14 of 17
(1,440 Views)

Hi Brian,

sorry, in this case, there was no compiler error, but if I run the program...it stops on the More Specific. vi  with this error message: Error 133182672 occurred at To More Specific Class

I think we need a other solution!!! The same problem I will occure on the output...Please help me!

thx thomas

0 Kudos
Message 15 of 17
(1,435 Views)
Attached is a zip file that contains my VS.NET project and assembly for a .NET class that takes a ref byte[]. Also included is a LV 8 VI that calls it. It works fine for me, so I'm not sure what problem you are running into. Please try this VI and make sure it works for you also. If it does, compare this VI to yours to make sure that the types and constants match up.
0 Kudos
Message 16 of 17
(1,431 Views)

Hey Brian,

thx for your help. Now all works fine. The error occures if no value is in the array. I'am very happy now!

regards thomas

0 Kudos
Message 17 of 17
(1,427 Views)