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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:39:30+00:00 2026-05-23T22:39:30+00:00

I’ve recently been trying to generate data contracts from xsd files, using svcutil like

  • 0

I’ve recently been trying to generate data contracts from xsd files, using svcutil like this:

svcutil.exe /t:code /dconly /out:MyContract.cs /n:*,My.Namespace MyDataDefinition.xsd

The XSD mostly consists of definitions like this:

<xsd:complexType name="SomeComplexObjectType">
    <xsd:sequence>
        <xsd:element name="FirstData" type="xsd:string" minOccurs="0" />
        <xsd:element name="SecondData" type="xsd:string" minOccurs="0" />
    </xsd:sequence>
</xsd:complexType>

svcutil generates something like this:

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Name="SomeComplexObjectType")]
public partial class PersonInfo : object, System.Runtime.Serialization.IExtensibleDataObject
{
    private string FirstDataField;
    private string SecondDataField;

    [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false)]
    public string FirstData
    {
        get
        {
            return this.FirstDataField;
        }
        set
        {
            this.FirstDataField= value;
        }
    }

    [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false)]
    public string SecondData
    {
        get
        {
            return this.SecondDataField;
        }
        set
        {
            this.SecondDataField= value;
        }
    }
}

Which works fine, however, the “EmitDefaultValue=false” attributes are not necessary. Not to mention that it introduces a lot of noise into the wsdl, adding stuff like this:

<xsd:element minOccurs="0" name="FirstData" nillable="true" type="xsd:string">
    <xsd:annotation>
        <xsd:appinfo>
            <DefaultValue xmlns="http://schemas.microsoft.com/2003/10/Serialization/" EmitDefaultValue="false"/>
        </xsd:appinfo>
    </xsd:annotation>
</xsd:element>

Currently I’m just hand-editing the generated contract, but that is not ideal from a maintenance standpoint.

Does anyone know how to prevent svcutil from automatically generating these EmitDefaultValue=false attributes?

  • 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-23T22:39:31+00:00Added an answer on May 23, 2026 at 10:39 pm

    Please see this article.

    On schema import, the EmitDefaultValue property is automatically set
    to false whenever the WCF-specific annotation mentioned previously is
    detected. It is also set to false for reference types that have the
    nillable property set to false to support specific interoperability
    scenarios that commonly occur when consuming ASP.NET Web services

    It appears your only choice is to modify the incoming schema so the relevant elements are nillable.

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

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a text area in my form which accepts all possible characters from

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.