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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:30:02+00:00 2026-06-15T16:30:02+00:00

I’m creating 2 wcf services – ADService & DBService. I’m using DTO’s called EmployeeDTO

  • 0

I’m creating 2 wcf services – ADService & DBService. I’m using DTO’s called EmployeeDTO and CustomerDTO to exchange data between endpoints.
I can’t add any of the services as Service References to other project in my solution and when I run the WCF host and try to access ADService.svc or DBService.svc I get the following:


    Type 'DTOs.CustomerDTO' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.  If the type is a collection, consider marking it with the CollectionDataContractAttribute.

and


    Type 'DTOs.EmployeeDTO' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.  If the type is a collection, consider marking it with the CollectionDataContractAttribute.

my files look as following:

class CustomerDTO


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace DTOs
    {
        public class CustomerDTO
        {
            public int customerID;
            public string name;
            public string surname;
            public string street;
            public string post_code;
            public string city;
            public string country;
            public string personal_code;
            public string phone_number;
            public string group_type;
            public string employee;

            public CustomerDTO(int _customerID, string _name, string _surname, string _street, string _post_code, string _city, string _country, string _personal_code, string _phone_number, string _group_type, string _employee)
            {
                this.customerID = _customerID;
                this.name = _name;
                this.surname = _surname;
                this.street = _street;
                this.post_code = _post_code;
                this.city = _city;
                this.country = _country;
                this.personal_code = _personal_code;
                this.phone_number = _phone_number;
                this.group_type = _group_type;
                this.employee = _employee;
            }
        }
    }

class EmployeeDTO:


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace DTOs
    {
        public class EmployeeDTO
        {
            public string givenName;
            public string sn;
            public string telephoneNumber;
            public string sAMAccountName;
            public string title;
            public string Department;
            public string distinguishedName;
            public string OU;
            public bool enable;

            public EmployeeDTO(string _givenName, string _sn, string _telephoneNumber, string _sAMAccountName, string _title, string _Department, string _distinguishedName, string _OU, bool _enable)
            {
                this.Department = _Department;
                this.distinguishedName = _distinguishedName;
                this.givenName = _givenName;
                this.sAMAccountName = _sAMAccountName;
                this.sn = _sn;
                this.telephoneNumber = _telephoneNumber;
                this.title = _title;
                this.OU = _OU;
                this.enable = _enable;
            }
        }
    }

Web.config

<?xml version="1.0"?>
<configuration>
  <connectionStrings>
    <add name="ki_dbEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=WIN-D3T41W1E5EB\SQLEXPRESS;Initial Catalog=ki_db;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/>
  </connectionStrings>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  <system.serviceModel>
    <services>
      <service name="WcfHost.ADService">
        <endpoint address="" binding="basicHttpBinding" contract="WcfHost.IADService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8733/WcfServiceLibrary/ADService/" />
          </baseAddresses>
        </host>
      </service>
      <service name="WcfHost.DBService">
        <endpoint address="" binding="basicHttpBinding" contract="WcfHost.IDBService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8733/WcfServiceLibrary/DBService/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>

</configuration>

IADService.cs


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.Serialization;
    using System.ServiceModel;
    using System.Text;
    using System.Threading.Tasks;
    using DTOs;
    using System.Security.Principal;

    namespace WcfHost
    {
        // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IADService" in both code and config file together.
        [ServiceContract]
        public interface IADService
        {
            [OperationContract]
            bool setConnection();
            .
            .
            .
            [OperationContract]
            Task changeAccountStatus(EmployeeDTO _employee);

        }
    }

IDBService.cs is defined analogically.

I can’t seem to find the cause of this error especially that a friend of mine has a similar implementation and it works while mine does not.
Any help would be deeply appreciated.

  • 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-15T16:30:03+00:00Added an answer on June 15, 2026 at 4:30 pm

    To serialize a class over the wire you need to mark it (as it says) with the DataContract and DataMember attribute. I believe you also need to convert those fields to properties. So you need:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace DTOs
    {
        [DataContract]
        public class CustomerDTO
        {
            [DataMember]
            public int customerID { get; set; }
    
            [DataMember]
            public string name { get; set; }
    
            [DataMember]
            public string surname { get; set; }
    
            [DataMember]
            public string street { get; set; }
    
            [DataMember]
            public string post_code { get; set; }
    
            [DataMember]
            public string city { get; set; }
    
            [DataMember]
            public string country { get; set; }
    
            [DataMember]
            public string personal_code { get; set; }
    
            [DataMember]
            public string phone_number { get; set; }
    
            [DataMember]
            public string group_type { get; set; }
    
            [DataMember]
            public string employee { get; set; }
    
            public CustomerDTO(int _customerID, string _name, string _surname, string _street, string _post_code, string _city, string _country, string _personal_code, string _phone_number, string _group_type, string _employee)
            {
                this.customerID = _customerID;
                this.name = _name;
                this.surname = _surname;
                this.street = _street;
                this.post_code = _post_code;
                this.city = _city;
                this.country = _country;
                this.personal_code = _personal_code;
                this.phone_number = _phone_number;
                this.group_type = _group_type;
                this.employee = _employee;
            }
        }
    }
    

    Because your operation contract uses the EmployeeDTO type as an input parameter, that means the client needs to be able to create that type and send it over the wire to the server. So it must be attributed with [DataContract].

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build

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.