Imagine the following VB.NET class:
Public Class P
Public Function GetDumbList() As List(Of DumbPeople)
Dim retList As New List(Of DumbPeople)
retList.Add Person1
retList.Add Person2
Return retList
End Function
End Class
Now we have the following classic ASP page:
<%
Dim P
Set P = Server.CreateObject("Project.Assembly.Namespace.P")
retList = P.GetDumbList()
...
...
...
%>
How do you use retList? I tried to loop using the following two methods:
1. For Each Person in retList
Throws an error "Object is not a collection"
2. For i = 0 To Ubound(retList)
Throws an error "Type mismatch: -More detail -
Thanks in advance for your help. Jake
UPDATE
Based on the help of Chris Haas, we were able to solve this problem. This requires a second helper function, ASPClassic, to convert List (of T) into an Object array; however, COM objects cannot expose common methods. Because of this, the input must be a specific type of list, which must be converted to an Object array. Solution below
Public Function DumbPeopleListToObjectArray(ByVal DPList As IList(Of DumbPeople)) As Object()
Return Array.ConvertAll(Of DumbPeople, Object)(DPList.ToArray(), New Converter(Of DumbPeople, Object)(Function(j) DirectCast(j, Object)))
End Function
, .
, - .