12-01-2015 06:29 AM
Good day everyone!
I am having a problem regarding the use of a dll in my labview program.
Heres all information I can imagine right now:
.net dll used for communication with a USB-device using the windows CDC-driver
C#-Header of the Method I try to call
public AnswerToCommand GetAnswerToCommand( byte[] response )
In Labview all methods prior to this seem to work fine. I can establish a connection and I get a "success"-message after sending my command.
When wiring and empty U8-array to this input, I get the error: (Message is in german so I tried to translate)
Error 1172
method System.Reflection.TargetInvocationException: caused an error
Inner Exception: System.IndexOutOfRangeException: index was out of the array range <append><b>System.IndexOutOfRangeException</b> in test.vi
I guess this has to do with the way, labview handles empty arrays.
So I wired a filled U8-array to this input (5-10000 values), then I get the following error: (Message is in german so I tried to translate)
Error 1172
method System.Reflection.TargetInvocationException: caused an error Inner Exception: System.OverflowException: Arithmetic operation caused an overflow <append><b>System.OverflowException</b> in test.vi
I am now unsure how to go from there. Any help is appreciated.
Kind regards,
Tim
12-01-2015 11:47 AM
Can we see the VI and/or the DLL in question?
If you're using a DLL which is truly .NET you should probably be using the .NET connectivity tools and not the old-style DLL interfaces.
12-01-2015 12:48 PM
@TimZweistein wrote:
Good day everyone!
I am having a problem regarding the use of a dll in my labview program.
Heres all information I can imagine right now:
.net dll used for communication with a USB-device using the windows CDC-driver
C#-Header of the Method I try to call
public AnswerToCommand GetAnswerToCommand( byte[] response )
In Labview all methods prior to this seem to work fine. I can establish a connection and I get a "success"-message after sending my command.
When wiring and empty U8-array to this input, I get the error: (Message is in german so I tried to translate)
Error 1172
method System.Reflection.TargetInvocationException: caused an error
Inner Exception: System.IndexOutOfRangeException: index was out of the array range <append><b>System.IndexOutOfRangeException</b> in test.vi
I guess this has to do with the way, labview handles empty arrays.
Actually this is more likely due to how the method in question handles parameters passed to the method. It likely doesn't check that the array is a valid size and thus when it operates on it it discovers that the size is invalid (an array[] size of 0 is valid). This is a usability bug in the method itself but you have discovered the workaround as you suggested below.
So I wired a filled U8-array to this input (5-10000 values), then I get the following error: (Message is in german so I tried to translate)
Error 1172
method System.Reflection.TargetInvocationException: caused an error Inner Exception: System.OverflowException: Arithmetic operation caused an overflow <append><b>System.OverflowException</b> in test.vi
I am now unsure how to go from there. Any help is appreciated.
Kind regards,
Tim
It si diofficult to tell what is causing the exception in the method you describe. Posting the .Net assembly may allow me to dig into the source and get a better appreciation but otherwise you need to use other tools as suggested. I'm afraid LabVIEW is not responsible for this one.