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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:11:16+00:00 2026-06-02T16:11:16+00:00

Is there any way to conditionally specify EmitDefaultValue at runtime for the DataContractSerializer in

  • 0

Is there any way to conditionally specify EmitDefaultValue at runtime for the DataContractSerializer in .NET? Are there any workarounds?

For example, I am curious whether I could use EmitDefaultValue=false for WCF serialization, but I would like to be able to use EmitDefaultValue=true for XMLs generated for external interfaces, such as print.

  • 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-02T16:11:17+00:00Added an answer on June 2, 2026 at 4:11 pm

    Well, two options you potentially have are to use a data contract surrogate or an IObjectReference. I think both of these are overkill for you, but if you really, really want to support this scenario on your end, maybe this is a sacrifice you’re willing to make. Note that using them also has significant implications for performance, interoperability, exposure via schema, etc.

    I also want to point out that what you’re trying to do — EmitDefaultValue of false — is not recommended for a number of reasons, even though I know what the common motivations are. See Why is using [DataMember(EmitDefaultValue = false)] not recommended?

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

Sidebar

Related Questions

Is there any way I can conditionally compile in my app based upon whether
Is there any way to conditionally ( based on report parameter for example )
Is there any way to do something conditionally in jquery only if IE6 is
Is there any way to use conditional statements in CSS?
Is there any way to update cookies across folders in PHP? For example, consider
Is there any other way of creating a conditional execution? way 1 : the
Is there any way to trigger a function that's called when the user types
:) Is there any way to create an index, and incrementing with a given
Is there any way to hover over an element that's already hidden. I am
Is there any way to simulate a try-finally or try-except in a language that

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.