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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:25:55+00:00 2026-05-22T20:25:55+00:00

In a solution, I added a WCF Service Library. No problem with the default

  • 0

In a solution, I added a “WCF Service Library”. No problem with the default method. I added one :

In the interface :

[ServiceContract]
public interface ISecurityAccessService
{
    [OperationContract]
    string GetData(int value);

    [OperationContract]
    CompositeType GetDataUsingDataContract(CompositeType composite);

    [OperationContract]
    CompositeUser ListUser();

}

[DataContract]
public class CompositeUser
{
    List<User> _listUser = new List<User>();

    [DataMember]
    public List<User> ListUser
    {
        get { return _listUser; }
        set { _listUser = value; }
    }
}

The interface implementation, the dataaccess iw working, I tested the DataService and no problem.

public class SecurityAccessService : ISecurityAccessService
{
    public CompositeUser ListUser()
    {
        DataAccess.DataService service = new DataAccess.DataService();

        CompositeUser compositeUser = new CompositeUser();
        compositeUser.ListUser = service.ListUser();

        return compositeUser;
    }
}

When I execute and try to invoke, I receive this error message :
*An error occurred while receiving the HTTP response to http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary/ISecurityAccessService/. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.*

The App.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <services>
      <service name="WcfServiceLibrary.SecurityAccessService">
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary/ISecurityAccessService/" />
          </baseAddresses>
        </host>
        <!-- Service Endpoints -->
        <!-- Unless fully qualified, address is relative to base address supplied above -->
        <endpoint address ="" binding="wsHttpBinding" contract="WcfServiceLibrary.ISecurityAccessService">
          <!-- 
              Upon deployment, the following identity element should be removed or replaced to reflect the 
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
              automatically.
          -->
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <!-- Metadata Endpoints -->
        <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
        <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

Update 1

I made a working sample with database access. I just don’t understand something in the “PersonService” class, why I have to make this loop. Solution is welcome.

Download 40ko .rar full example

  • 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-05-22T20:25:56+00:00Added an answer on May 22, 2026 at 8:25 pm

    your User class needs to be marked with the DataContract attribute and its methods with the DataMember attribute. It may also need to be marked as a KnownType in the CompositeUser class so that it is included in the types for the service. You can do that like so:

    [DataContract]
    [KnownType(typeof(User))]
    public class CompositeUser
    {
    ...
    }
    

    you’ll be able to tell what the issue is from the logs. Either you’ll get a ‘cannot be serialized’ message, in which case you need to add the [DataContract] attribute or it will be ‘type was not expected’ in which case you’ll also need to add the [KnownType] attribute

    If you enable tracing in your service you’ll be able to get more details of what the problem was. Add something like this in the config file:

    <configuration>
      <system.diagnostics>
         <trace autoflush="true"/>
          <sources>
             <source name="System.ServiceModel" switchValue="Verbose">
                <listeners>
                   <add name="sdt" type="System.Diagnostics.XmlWriterTraceListener" initializeData="D:\wcfLog.svcLog"/>
               </listeners>
             </source>
          </sources>
        </system.diagnostics>
    </configuration>
    

    also setting <serviceDebug includeExceptionDetailInFaults="True" />

    will allow more detail about the error to be returned in the service exception which might also help.

    EDIT

    From the comments below it seems the User class is a Linq to SQL generated class. I don’t think you should be sending this class across the wire. WCF deals with messages not in serializing types with behaviour, so you should create a DTO which represents the data in your User class that will be needed on the client and send this DTO out from the service contract. Even if you do send the User class as it is, when it gets to the client it won’t have the context to still be connected to the DB.

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

Sidebar

Related Questions

There are two projects in one VS solution: client(wpf app) and а wcf service
I created one solution and then added one project which contains all WCF services.
I created a very simple WCF class library and added this project to the
I have a WCF service running, I added a reference to the service by
I have a VS2010 (RTM) solution which contains: WCF Service project Console WCF client
I've got a Visual Studio 2008 solution with a WCF service, and a client.
I added a text file to a testapp's solution and I want to read
I've Added a setup project to my solution (didn't use the wizard) I then
So I added an EXE to my project's solution. The EXE does some stuff
I've added a proxy to a webservice to a VS2008/.NET 3.5 solution. When constructing

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.