NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Dotnet type StringBuilder not working as step parameter type

Solved!
Go to solution

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

0 Kudos
Message 1 of 3
(2,747 Views)

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

0 Kudos
Message 2 of 3
(2,718 Views)
Solution
Accepted by topic author OnlyOne

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();
}

0 Kudos
Message 3 of 3
(2,713 Views)