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

  • Home
  • SEARCH
  • 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 101475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:46:41+00:00 2026-05-11T00:46:41+00:00

I’m not certain where the error is resulting (from silverlight, from wcf, something else…)

  • 0

I’m not certain where the error is resulting (from silverlight, from wcf, something else…) but, I have a WCF service being called from Silverlight. The method returns a class, with a property that does not have a setter. This throws an error. If I add a setter to the property then it does not give an error.

The error is the usual impenetrable and unhelpful Silverlight error message, but…

[Serializable]   [DataContract]   public SomeClass {       DataMember]       public string PropertyA { get; set; }       public string PropertyB { get { return 'Hi There'; } }   }   

Throws an error…

But change it to:

[Serializable]   [DataContract]   public SomeClass {        [DataMember]        public string PropertyA { get; set; }        public string PropertyB { get { return 'Hi There'; } set {} }   }   

No error.

Includes the usual ISomeService.svc & SomeService.svc class, references updated in Silverlight calling the client async, etc., etc.

What is the correct way to configure the property (some attribute other than ‘DataMember’ to allow a get-only, or a private-set property) to pass it over the wire?

  • 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-11T00:46:42+00:00Added an answer on May 11, 2026 at 12:46 am

    In your example PropertyB is not marked with a DataMember attribute meaning that it won’t be exposed in the WSDL and ignored by the serializer. But if you mark PropertyB with a DataMember then you must have a setter (private, proptected or public) in order to serialize it correctly otherwise you may get an exception. There are two ways I can think of having read-only properties serialized over the wire:

    [DataContract] public class SomeClass {      public SomeClass()     {         _propertyB = 'Hi there';     }      [DataMember(Name='PropertyB')]     private readonly string _propertyB;      public string PropertyB     {         get { return _propertyB; }     } } 

    Or this:

    [DataContract] public class SomeClass {      public SomeClass()     {         PorpertyB = 'Hi there';     }      [DataMember]     public string PropertyB     {         get;         private set;     } } 

    Please note that if you use svcutil.exe, the generated proxy class will have both public getter and setter for the property which might not be what you are looking for. In this case you can use the service contract and data contract assemblies on the client side.

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

Sidebar

Ask A Question

Stats

  • Questions 121k
  • Answers 121k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer From MSDN documentation for TypeConverter.IsValid: The IsValid method is used… May 12, 2026 at 12:32 am
  • Editorial Team
    Editorial Team added an answer I think it really depends on what sort of API… May 12, 2026 at 12:32 am
  • Editorial Team
    Editorial Team added an answer i found in this link : http://phplens.com/lens/php-book/optimizing-debugging-php.php A function call… May 12, 2026 at 12:32 am

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.