New Posts New Posts RSS Feed: InvokeServerMethodAsync returning Array
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

InvokeServerMethodAsync returning Array

 Post Reply Post Reply
Author
leeatkinson View Drop Down
Newbie
Newbie


Joined: 01-Jul-2010
Posts: 17
Post Options Post Options   Quote leeatkinson Quote  Post ReplyReply Direct Link To This Post Topic: InvokeServerMethodAsync returning Array
    Posted: 07-Jul-2010 at 9:37am
Hi

I want to return an Array (of Guid) using InvokeServerMethodAsync but the call fails with the exception "The remote server returned an error: NotFound."

If I return a single Guid, it works fine.

Is it possible to return an Array?

Lee

Back to Top
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post Posted: 07-Jul-2010 at 6:34pm
Yes, but in this case, .NET is having difficulty serializing the value.  Try using the typed list below instead of an array.  It has most of the serialziation markup for .NET to discover.  (You may also have success just using one of the other .NET collection classes.) 
 
  [System.Runtime.Serialization.DataContract]
  public class GuidList : List<Guid>, IKnownType {
    public GuidList() : base() {}
  }
 
In the worst case, you would create your own custom class, use the [DataContract] attribute on the class, add the IKnownType marker interface, and mark each serializable property with the [DataMember] attribute.
 


Edited by ting - 07-Jul-2010 at 6:36pm
Back to Top
leeatkinson View Drop Down
Newbie
Newbie


Joined: 01-Jul-2010
Posts: 17
Post Options Post Options   Quote leeatkinson Quote  Post ReplyReply Direct Link To This Post Posted: 08-Jul-2010 at 2:54am
Thanks for your reply

I thought that Arrays were 'WCF-serializable' by default. Or perhaps is DevForce doing something which prevents Arrays working 'out of the box'?

Lee
Back to Top
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post Posted: 08-Jul-2010 at 3:00pm
Because the return type of InvokeServerMethod is Object, .NET's serialization behavior may not be as clean.  Were you able to get it working?
Back to Top
leeatkinson View Drop Down
Newbie
Newbie


Joined: 01-Jul-2010
Posts: 17
Post Options Post Options   Quote leeatkinson Quote  Post ReplyReply Direct Link To This Post Posted: 08-Jul-2010 at 10:49pm
Yes I was, by creating the class as you suggested.

Lee
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down