08-12-2010 11:51 AM
I'm trying to pass a .NET struct back into a dll so that it can do further processing. However, if that struct contains an array, I get the
"
An error occurred within the .NET code.An error occurred while evaluating the expression for the element 'T1'.
All input parameters must have an expression specified." error from TestStand.
If I try to statically define the size of the array in the .NET struct, I get
"The array for the parameter 'T1' is an input parameter and is empty.
All input parameters must have an expression specified."
I'm sure that the array in TestStand is not empty, as I've tried creating an array of 10, populated it with values and tried to send that.
If it helps, T1 is an array inside the struct. I've tried defining the struct array as [0...empty] and as a static array [0...9]
Any help would be appreciated.
08-12-2010 01:08 PM
Hi,
Can you give a little more information? Namely:
1) What version of TestStand are you using?
2) What else is contained in your struct besides your array?
3) What does the method you are calling look like (can you post the method prototype)?
4) I'm assuming you created a type from the struct and are passing a variable of that type in as the parameter?
-Jeff
08-12-2010 01:47 PM
1) I'm using TestStand 4.2
2) The struct contains numerous other numbers and strings, but I've also tried creating a struct that has nothing but an array in it, the problem persists
3) The method is empty, and all it does is accept a parameter of the type of my struct
4) I have tried creating a type from the struct and passing the struct as a variable, and I've also tried creating a constructor for the struct and use the create object feature to create a .NET object and try to pass that. Both have failed.
08-12-2010 02:15 PM
What is the type of your array inside your struct?
08-12-2010 02:34 PM
It's a double array (so array of number)
08-12-2010 02:47 PM
I believe there are issues when passing empty arrays in TestStand 4.2. I got the same error as you when I created a type from a struct and then left the array empty and tried to pass it. However, if I just changed the array to not be empty (in variables view) it worked. You are seeing the same error even if the array is not empty? Have you tried just declaring a non-empty array of numbers and passing it as the array element of the struct parameter? Does this also give an error?
-Jeff
08-12-2010 09:19 PM
Yes, I have tried creating a an array, setting it as non empty (making sure the 'Empty' checkbox is unchecked), changed the values to non-zero, and tried passing it to .NET, with no luck.
08-13-2010 10:26 AM
Any chance you can provide a simple seq file and dll that reproduce this? I believe I've tried exactly what you are describing and do not see an error. Maybe there is some subtle difference.
08-13-2010 01:15 PM
I've attached a test sequence file with a struct
The class library dll it's accessing has one file, with the following code
using System;
using System.Collections.Generic;
using System.Text;
namespace ClassLibrary1
{
public struct myStruct
{
double[] array;
}
public static class myClass
{
public static void TestFunction(myStruct pstruct)
{
}
}
}
Let me know if you can reproduce it with this setup and/or if I'm doing something wrong
08-13-2010 02:14 PM
When I change your array to be non-empty I don't get the same error anymore. Instead I get an error that the class info for myClass was not found. It looks like TestStand is not finding it at runtime because it is declared as a static class. I removed the static keyword (from just the class, not the method) and then it worked. Let me know if this works for you and if so if it is an acceptable workaround.