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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:33:52+00:00 2026-05-10T16:33:52+00:00

I have a WCF service hosted for internal clients – we have control of

  • 0

I have a WCF service hosted for internal clients – we have control of all the clients. We will therefore be using a data contracts library to negate the need for proxy generation. I would like to use some readonly properties and have some datacontracts without default constructors. Thanks for your help…

  • 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. 2026-05-10T16:33:52+00:00Added an answer on May 10, 2026 at 4:33 pm

    Readonly properties are fine as long as you mark the (non-readonly) field as the [DataMember], not the property. Unlike XmlSerializer, IIRC DataContractSerializer doesn’t use the default ctor – it uses a separate reflection mechanism to create uninitialized instances. Except on mono’s ‘Olive‘ (WCF port), where it does use the default ctor (at the moment, or at some point in the recent past).

    Example:

    using System; using System.IO; using System.Runtime.Serialization; [DataContract] class Foo {     [DataMember(Name='Bar')]     private string bar;      public string Bar { get { return bar; } }      public Foo(string bar) { this.bar = bar; } } static class Program {     static void Main()     {         DataContractSerializer dcs = new DataContractSerializer(typeof(Foo));         MemoryStream ms = new MemoryStream();         Foo orig = new Foo('abc');         dcs.WriteObject(ms, orig);         ms.Position = 0;         Foo clone = (Foo)dcs.ReadObject(ms);         Console.WriteLine(clone.Bar);     } } 
    • 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 library that is hosted in a windows service. I
I have a WCF service hosted in IIS 7 using HTTPS. When I browse
I am writing a web service using WCF. I created data contracts. I created
I have a WCF service hosted on IIS6 and I am using .net framework
I have a single instance WCF service class that is self hosted using a
I have a WCF service hosted in IIS. The intention is for clients to
I have a WCF service hosted in WAS using net.tcp. Am I correct in
I have a WCF service hosted in IIS. The intention is for clients to
Hi All I have written a wcf service and hosted it on windows service.
I have a WCF service hosted in IIS and want to gain access to

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.