03-14-2017 05:06 AM
Hello,
i created some functions in C# that i want to use in TestStand.
One of them looks like this:
public void myfunction(int a, ref int b, StringBuilder c)
{
//somecode
}
When i insert this in teststand 2016 and run the step i get a Run-Time Error:
An error occurred while calling .NET member 'myfunction':
Object of type 'System.__ComObject' cannot be converted to type 'System.Text.StringBuilder'.
Errorcode: -17500; Operation Failed.
Question: Is it not possible to use type StringBuilder?
Thx
Solved! Go to Solution.
03-14-2017 09:15 AM - edited 03-14-2017 09:16 AM
Are you constructing a StringBuilder object and passing that in or trying to pass in just a teststand string? If it's the later try the former. TestStand strings implicitly convert to System.String, but not StringBuilder. You have to explicitly create a StringBuilder object using a separate TestStand step with a StringBuilder constructor call and store that StringBuilder object in an object reference variable and use that with your .NET step requiring a StringBuilder object.
Hope this helps,
-Doug
03-14-2017 09:29 AM
Thx for your help.
Meanwhile i converted the Stringbuilder into a string by using a temp-variable in my sourcecode.
public void myfunction(int a, ref int b, string c)
{
c_temp = new StringBuilder(500);
//somecode creating content of c_temp
c = c_temp.ToString();
}