Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8437029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:19:35+00:00 2026-06-10T07:19:35+00:00

Any example of WCF client server providing of List or Array of custom class

  • 0

Any example of WCF client server providing of List or Array of custom class objects would help me! But here is what I have got so far:

Here is my class system I want to provide

namespace NEN_Server.FS {
    [Serializable()]
    public class XFS {
        private List<NFS> files;
        public XFS() {
            files = new List<NFS>();
            }
        public List<NFS> Files {
            get { return files; }
            set { files = value; }
            }
        }
    }

where NFS is

namespace NEN_FS {
    public interface INFS : IEquatable<NFS> {
        string Path { get; set; }
        }
    [Serializable()]
    abstract public class NFS : INFS {
        abstract public string Path { get; set; }
        public NFS() {
            Path = "";
            }
        public NFS(string path) {
            Path = path;
            }
        public override bool Equals(object obj) {
            NFS other = obj as NFS;
            return (other != null) && ((IEquatable<NFS>)this).Equals(other);
            }
        bool IEquatable<NFS>.Equals(NFS other) {
            return Path.Equals(other.Path);
            }
        public override int GetHashCode() {
            return Path != null ? Path.GetHashCode() : base.GetHashCode();
            }
        }
    }

and providing method is :

namespace NEN_Server.WCF {
    public class NEN : INEN {
        private MMF mmf;
        public NEN() {
            mmf = new MMF();
            }
        public string GetRandomCustomerName() {
            return mmf.MMFS.Files[0].Path;
            }
        public NFS[] ls() {
            return mmf.MMFS.Files.ToArray();
            }

Interface is

<ServiceContract>
Public Interface INEN
    <OperationContract>
    Function GetRandomCustomerName() As String
    <OperationContract()>
    Function ls() As NFS()

and finally I do:

%svcutil% /language:cs /out:NEN_Protocol\NEN.cs http://localhost:8080/NEN_Server

it generates :

public NEN_FS.NFS[] ls()
{
    return base.Channel.ls();
}

I call it in my client application let files = nen.ls() and it fails with :

An unhandled exception of type 'System.ServiceModel.CommunicationException' occurred in mscorlib.dll

Additional information: The underlying connection was closed: The connection was closed unexpectedly.

on return base.Channel.ls(); line of code.

Note that providing string mmf.MMFS.Files[0].Path; works just fine

Why? What am I doing wrong? 🙂

All the code is available on GitHub : https://github.com/nCdy/NENFS

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:19:36+00:00Added an answer on June 10, 2026 at 7:19 am

    It seems to me, that fault reason is here: abstract public class NFS.
    The first, consider using of data contracts with WCF:

    [DataContract(IsReference = true)]
    abstract public class NFS : INFS 
    {
      [DataMember]
      abstract public string Path { get; set; }
    
      // the rest of code here
    }
    

    The second, specify known types for your data contract. Serializers on both side of a communication channel have to know, how to seralize/deserialize concrete NFS‘ descendant type:

    [DataContract(IsReference = true)]
    [KnownType(typeof(NFS1))]
    [KnownType(typeof(NFS2))]
    abstract public class NFS : INFS 
    {
      [DataMember]
      abstract public string Path { get; set; }
    
      // the rest of code here
    }
    
    public class NFS1 : NFS {}
    public class NFS2 : NFS {}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have installed Visual Studio 2012 RC. I would like to find any example
I would like to set up a WCF service so that any changes a
I'm using .NET 3.5 and WCF for developing a server-client application. Binding=BasicHttp. I'm working
I have WCF RESTful service and Android client. Server replies with 400 when I
See also How does a WCF server inform a WCF client about changes? (Better
If I have a WCF server app that need to inform WCF client that
I am working on WCF client-server app. where the client has to be constantly
Is there any example on how to implement a simple login page/dialog? I have
is there any example on using java method to call rhino-javascript function and return
Is there any example on DOS Batch - Find and Replace command for files?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.