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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:57:02+00:00 2026-05-28T15:57:02+00:00

I’m getting the following exception trying to pass an object through wcf: There was

  • 0

I’m getting the following exception trying to pass an object through wcf:

There was an error while trying to serialize parameter http://tempuri.org/:item. The InnerException message was ‘Enum value ‘-1’ is invalid for type ‘Models.SubModels.DamageLocations’ and cannot be serialized. Ensure that the necessary enum values are present and are marked with EnumMemberAttribute attribute if the type has DataContractAttribute attribute.’. Please see InnerException for more details.

It is defined like:

[DataContract]
public class Property
{
    [DataMember]
    public PropertyDamage Damage { get; set; }

    public Property()
    {
        this.Damage = new PropertyDamage();
    }
}

And PropertyDamage:

[DataContract]
public enum DamageLocations
{
    [EnumMember]
    Unknown=0,
    [EnumMember]
    Front,
    [EnumMember]
    Rear
}

[DataContract]
public class PropertyDamage
{
    [Display(Name="Location of Damage:")]
    [DataMember(IsRequired=true)]
    public DamageLocations DamageLocation { get; set; }
}

edit – this also causes the same error:

public enum DamageLocations
{
    Unknown=0,
    Front=1,
    Rear=2
}

edit 2- Adding a default value for the enum in the ctor did not change the error:

    public PropertyDamage()
    {
        this.DamageLocation = DamageLocations.Unknown; //0
    }

Trying to research the problem, I see people getting a similiar error “Enum value ‘0’ is invalid”, and the solution was to add a 0 to the enum.

I already have a 0 item though, and the error states -1 is invalid.

What is the proper way to resolve this?

edit3 – It appears the -1’s are coming from the post data, this is the post data from submitting the page.

Damage.DamageLocation=-1
  • 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-28T15:57:03+00:00Added an answer on May 28, 2026 at 3:57 pm

    It sounds simply like your data has the value -1.

    Enums are just fancy integers. You can assign any value to an enum (within the range of the underlying type); for example:

    enum Foo { Bar = 1 }
    ...
    Foo foo = (Foo)1035; // perfectly fine
    

    This is fine in c# but not in most serialization libraries, especially those which want to encode it as names (XmlSerializer, DataContractSerializer, etc).

    So: if -1 is not a defined value of your enums, don’t use that value in your data. If -1 has a meaning, define it in the enum.

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

Sidebar

Related Questions

I am trying to loop through a bunch of documents I have to put
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
i got an object with contents of html markup in it, for example: string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

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.