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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:50:28+00:00 2026-06-13T03:50:28+00:00

Hello I have an error 500 (internal server error) when I run the code

  • 0

Hello I have an error 500 (internal server error) when I run the code below. My issue is that I have no trace at all of the error. It seems that visual studio is unable to catch it.

The following code returns a Candidate if I try to add pers to candidate the code fail and i get error 500. The thing is PersonAddressDescription implement AddressDescription is inheritance the problem ?

public class CheckController : ApiController
{
    public Candidate Get()
    {
        PersonAddressDescription pers = new PersonAddressDescription();

        Candidate candidate = new Candidate();

        //IF I REMOVE THIS NO PROBLEM
        candidate.address = pers;

        return candidate;
    }
}

AddressDescription class

/// <remarks/>
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(CompanyAddressDescription))]
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(PersonAddressDescription))]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.17626")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.crif-online.ch/webservices/crifsoapservice/v1.00")]
    public abstract partial class AddressDescription : object, System.ComponentModel.INotifyPropertyChanged {

        private Location locationField;

        private ContactItem[] contactItemsField;

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Order=0)]
        public Location location {
            get {
                return this.locationField;
            }
            set {
                this.locationField = value;
                this.RaisePropertyChanged("location");
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute("contactItems", Order=1)]
        public ContactItem[] contactItems {
            get {
                return this.contactItemsField;
            }
            set {
                this.contactItemsField = value;
                this.RaisePropertyChanged("contactItems");
            }
        }

        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

        protected void RaisePropertyChanged(string propertyName) {
            System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
            if ((propertyChanged != null)) {
                propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
            }
        }
    }

PersonAddressDescription class that implement AddressDescription

/// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.17626")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.crif-online.ch/webservices/crifsoapservice/v1.00")]
    public partial class PersonAddressDescription : AddressDescription {

        private string firstNameField;

        private string lastNameField;

        private string maidenNameField;

        private Sex sexField;

        private bool sexFieldSpecified;

        private string birthDateField;

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Order=0)]
        public string firstName {
            get {
                return this.firstNameField;
            }
            set {
                this.firstNameField = value;
                this.RaisePropertyChanged("firstName");
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Order=1)]
        public string lastName {
            get {
                return this.lastNameField;
            }
            set {
                this.lastNameField = value;
                this.RaisePropertyChanged("lastName");
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Order=2)]
        public string maidenName {
            get {
                return this.maidenNameField;
            }
            set {
                this.maidenNameField = value;
                this.RaisePropertyChanged("maidenName");
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Order=3)]
        public Sex sex {
            get {
                return this.sexField;
            }
            set {
                this.sexField = value;
                this.RaisePropertyChanged("sex");
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlIgnoreAttribute()]
        public bool sexSpecified {
            get {
                return this.sexFieldSpecified;
            }
            set {
                this.sexFieldSpecified = value;
                this.RaisePropertyChanged("sexSpecified");
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Order=4)]
        public string birthDate {
            get {
                return this.birthDateField;
            }
            set {
                this.birthDateField = value;
                this.RaisePropertyChanged("birthDate");
            }
        }
    }
  • 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-13T03:50:29+00:00Added an answer on June 13, 2026 at 3:50 am

    I suspect that the object you retrieved (addResp) contains circular references somewhere in its object graph. Circular references cannot be JSON serialized.

    For example try putting the following code inside your controller to test what happens when you attempt to JSON serialize this instance:

    TypeIdentifyAddressResponse addResp = ws.identifyAddress("test");
    string json = JsonConvert.SerializeObject(addResp);
    


    UPDATE:

    It seems that AddressDescription is an abstract class and your actual instance is PersonAddressDescription. You need to indicate that to the serializer by using the [KnownType] attribute:

    [KnownType(typeof(PersonAddressDescription))]
    [KnownType(typeof(CompanyAddressDescription))]
    ...
    public abstract partial class AddressDescription : object, System.ComponentModel.INotifyPropertyChanged {
    {
        ...
    }
    

    As an alternative if you don’t want to further pollute your (already polluted) domain models with other attributes you could also define the known type inside your WebApiConfig.cs:

    config.Formatters.XmlFormatter.SetSerializer<Candidate>(
        new DataContractSerializer(typeof(Candidate),
        new Type[] { typeof(PersonAddressDescription) }));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello I have my code that connects to my ftp server $conn_id = ftp_connect($ftp_server);
Hello I have this code with a compiler error (error is from Microsoft Visual
Hello i have error when i am forwarding page without parameter. that is happen
Hello I have an extended stored procedure that sends an error message. srv_sendmsg(pSrvProc, SRV_MSG_ERROR,
Hello recently i have taken a backup of my server files & deleted all
I have two arrays: $array1 = array(1=>1,10=>1,12=>0,13=>13); $array2 = array(1=>Hello,10=>Test,12=>check,13=>error); Here $array1 has keys
Hello I have a datatable that I would like to filter with a single
So I am getting a 500 server error when attempting to bring up a
Hello i have this foreach loop that gives weird result , it displays only
Hello I have this problem with PyQt4-dev-tools that include: * a user interface compiler

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.