Results 1 to 3 of 3

Thread: [RESOLVED] Return List<T> will fail on WCF

  1. #1

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,605

    Resolved [RESOLVED] Return List<T> will fail on WCF

    So, i have this class that is referenced in both client and server app:
    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Runtime.Serialization;
    using System.Runtime.Serialization.Json;
    
    
    namespace WcfDataService
    {
        [DataContract]
        [Serializable]
        public class MainDataClassLocal
        {
    
            [DataMember(Name= "AllowDBNull")]
            public bool AllowDBNull { get; set; }
            [DataMember(Name = "Caption")]
            public string Caption { get; set; }
            [DataMember(Name = "ColumnName")]
            public string ColumnName { get; set; }
            [DataMember(Name = "Datatype")]       
            public string Datatype { get; set; }
            [DataMember(Name = "MaxLength")]
            public int MaxLength { get; set; }
            [DataMember(Name = "Readonly")]
            public bool Readonly { get; set; }
        }
    
        [DataContract]
        [Serializable]
        public class RootObjectLocal
        {
            public List<MainDataClassLocal> maindataclassLocal { get; set; }
        }
    
       
    }
    However when i pass it from the client app to WCF with data, i get an empty class (=null) . I went to the client service configuration and changed the type to system.collection.generic.list but still it will return null.
    Any help?
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  2. #2
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    Re: Return List<T> will fail on WCF

    It probably isn't being serialized - because it isn't marked with a DataMember

    Also look at : CollectionDataContract to make the serialisation "nicer".

  3. #3

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,605

    Re: Return List<T> will fail on WCF

    YES! Finally! SHT FK FK FK FK FK FK. One day lost for one line of code!
    Thanks man!
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width