This might be a stupid question, but I'd appreciate any help you could offer.
I'm trying to pass an array of objects back to a Web service.
The Web service expects this:
Dim Recipients() as WS.Recipient
but it won't let me create an object array of this type directly, so I'm
creating an ArrayList object and using CType to convert it, like so:
Dim WS as <my Web service>
Dim notification As New WS.Notification
Dim recipient As New WS.Recipient
Dim recipientList As New ArrayList
recipient.Name = "NameGoesHere"
recipient.Type = WS.AclType.User
recipientList.Add(recipient)
With Notification
.Message = "Test Message"
.Subject = "Test Subject"
.Recipients = CType(recipientList.ToArray, WS.Recipient())
End With
I get a "specified cast is not valid" error when it runs, but it seems to work
in the debugger; I get this from the debugger when I pause it before the
offending line:
? ctype(recipientList.ToArray, WS.Recipient())
{Length=1}
(0): {WinFormsTestArea.WS.Recipient}
So it seems to be giving me what I want. What am I doing wrong?