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 8195333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:06:06+00:00 2026-06-07T05:06:06+00:00

I have a WCF service and client in the same solution (different projects). The

  • 0

I have a WCF service and client in the same solution (different projects). The service class itself inherits from an interface, and that interface is shared between client and server (via a linked file). The client uses a service factory to generate a proxy. This has proved a really nice way to link the two sides without referencing the server-side project from the client.

One of the service methods returns an object that includes the DataContract and DataMember attributes, and until recently this class was linked to the client as well, but the server-side logic was excluded from the client using compilation symbols.

I decided it would be more sensible to turn this into an interface as well. But now I get the following exception every time the service method is called from the client:

The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.

Its inner exception is as follows:

Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

So by way of simplified example, my service essentially shares the following interface with the client:

public interface IMyData
{
    [DataMember]
    int Id {get; set;}

    [DataMember]
    string Description {get; set;}
}

The actual object that the interface works with and will return looks something like this:

[DataContract]
public class MyData : IMyData
{
    [DataMember]
    public int Id {get; set;}

    [DataMember]
    public string Description {get; set;}
}

The interface of my service looks something like this:

[ServiceContract]
public interface IMyService
{
    [OperationContract]
    IMyData GetData();
}

The implementation looks something like this:

[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single, InstanceContextMode = InstanceContextMode.Single)]
public class MyService : IMyService
{
    [OperationContract]
    IMyData GetData()
    {
        // Get data.
    }
}

Hope that all makes a little sense! I’m just wondering if I’m doing this all wrong. I’ll just go back to sharing the class and sectioning off the server-side-only code if I have to .. but I’d rather use an interface if I can.

Any ideas?

  • 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-07T05:06:08+00:00Added an answer on June 7, 2026 at 5:06 am

    There is no benefit to putting an interface on a DataContract as they simply represent data and no logic. You typically put those DataContracts inside the same assembly with the ServiceContracts or a separate assembly all together. This will prevent exposing the business logic to your clients.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WCF service that receive query from a silverlight client and send
I have a WCF client/service app that relies on secure communication between two machines
I have a WCF Service that I want my client to be able to
HI, I neet to pass chunk data from WCF service to client. I have
I have a simple WCF service that will analyse a raw text extracted from
I have WCF Class library, WCF Service Client and WCF Service Server in one
I'm practicing using WCF with two projects in the same solution. The service is
I have a WCF Web Service which is referenced from a class library. After
I have a WCF service as part of a client/server application I am working
I have a WCF service with a function GetData() When my client calls this

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.