All, I am trying to access a .NET dll registered as a COM Object with PowerBuilder 10. I keep running into problems where .NET objects return lists.
I have built out a very simple class for a proof of concept, and to better explain what I am encountering. See below:
.NET:
public class ListsArrays
{
public int[] GetArray()
{
int[] array = new int[3];
array[0] = 1;
array[1] = 10;
array[2] = 100;
return array;
}
public List<int> GetList()
{
List<int> list = new List<int>();
list.Add(3);
list.Add(33);
list.Add(333);
return list;
}
public int[] GetListArray()
{
List<int> list = new List<int>();
list.Add(3);
list.Add(33);
list.Add(333);
return list.ToArray();
}
}
PowerBuilder:
Integer ls_array[]
Integer obj_return, ID, netVal
String FullName
OleObject lo_dotnetobject
OleObject lo_Value
lo_Value = Create OleObject
lo_dotnetobject = Create OleObject
obj_return = lo_dotnetobject.ConnectToNewObject("XXX.ListsArrays")
//This is the tricky part
ls_array = lo_dotnetobject.GetArray() // WORKS (1)
ls_array = lo_dotnetobject.GetList().ToArray() // DOES NOT WORK (2)
lo_dotnetobject.GetList().CopyTo(ls_array) // DOES NOT WORK (3)
ls_array = lo_dotnetobject.GetListArray() // WORKS (4)
For each part that “DOES NOT WORK” I receive this error message:
“Function/event with no return value used in expression at line”
Obviously, I could just wrap my .NET assembly, and return an array for every list, but I would like to be able to handle lists on the PowerBuilder side without wrapping the .NET. Does anyone have any ideas? The fact that (4) works and (2) doesn’t work drives me kind of nuts.
Thanks.