Print Page | Close Window

InvokeServerMethodAsync returning Array

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1950
Printed Date: 27-Jan-2026 at 4:13pm


Topic: InvokeServerMethodAsync returning Array
Posted By: leeatkinson
Subject: InvokeServerMethodAsync returning Array
Date 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




Replies:
Posted By: ting
Date 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.
 


Posted By: leeatkinson
Date 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


Posted By: ting
Date 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?


Posted By: leeatkinson
Date Posted: 08-Jul-2010 at 10:49pm
Yes I was, by creating the class as you suggested.

Lee



Print Page | Close Window