accessing an external c# method which returns an array with UFT
Question ID: 107755
1
0

I have a C# method I am accessing using DotNetFactory, which returns an array. I am having difficulty getting UFT 12.54 to recognize the return value as an array and am not sure what I am doing wrong.
In the C# project the method’s return type is "string[]"

In UFT my call to the method is:

Dim oStrategyUI
Set oStrategyUI = DOTNetFactory.CreateInstance("AutomationLibrary.StrategyBlockUI", [path to dll])
myDecs = oStartegyUI.GetAllDeclarationsUI ("S_001")

In Variables datatable myDecs shows a value of "System.String[]"

Does anyone know a way to do this, or am I better off going back to my C# code and changing the return type to a delimited string?

Thanks

Marked as spam
Posted by (Questions: 3, Answers: 1)
Asked on July 21, 2017 8:41 pm
137 views
Answers (2)
0
Private answer

@bubblehead712
I am using UFT GUI, and the dll referenced with DOTNetFactory is C# using Visual Studio 2013

Marked as spam
Posted by (Questions: 3, Answers: 1)
Answered on July 25, 2017 11:56 am
0
Private answer

I have never return a String array from dll to vbscript but here are couple ideas''

1. Since the return is string array VBS engine could not intrepid it. Recommend convert array to string delimited and convert in VBS.
2. Since the return is string array which is object. Have you declared the VBS object before assigning it a value?
Dim myArray()
3. VBScript returns all varilables as type variant. Have you tried to change the DLL return object array and not string array? For example:

public object[] testStringArray()
{
object[] hello = new object[3];
hello[0] = ''hi''; hello[1] = ''bye''; hello[2] = ''shy'';
return hello;
}

Option 3 came from article ''[Return string array with vbscript problem](https://community.ptc.com/t5/PTC-Mathcad-Questions/Return-string-array-with-vbscript-problem/m-p/224197/highlight/true)''

Marked as spam
Posted by (Questions: 2, Answers: 98)
Answered on July 25, 2017 1:00 pm
0
I ended up using a variant of option 3 - modified the dll to return a delimited string. It seems to be working now. Thanks.
( at September 1, 2017 11:50 am)
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top