By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 1,077 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

Need help passing object array to Web service

P: n/a
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?
Jul 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.