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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:30:48+00:00 2026-05-31T18:30:48+00:00

An unhandled exception of type ‘System.StackOverflowException’ occurred in wcfserviceLibrary.DLL the code is show as

  • 0

An unhandled exception of type ‘System.StackOverflowException’ occurred in wcfserviceLibrary.DLL

the code is show as follows.

[DataContract]
public class memberdesignations
{
    [DataMember]
    public string DesigId
    {
        get { return DesigId; }
        set { DesigId = value;}
    }
    [DataMember]
    public string DesignationName
    {
        get { return DesignationName; }
        set { DesignationName = value; }
    }

}

then i have method of Type memberdesignations as follows

public List<memberdesignations> memberdesignations()
    {
        List<memberdesignations> designations = new List<memberdesignations>();
        memberdesignations objmemDesignations;
        ds = objbll.Get_Member_Designations();
        DataView dv = new DataView();
        dv = ds.Tables[0].DefaultView;
        foreach (DataRowView drow in dv)
        {
            objmemDesignations = new memberdesignations();
            objmemDesignations.DesigId = drow["DesignationId"].ToString();
            objmemDesignations.DesignationName = drow["DesignationName"].ToString();
            designations.Add(objmemDesignations);
        }
        return designations;
    }

iam getting the error in the class containing the get set properties.

But i was able to get rid of the error when i modified the class like this :

 [DataContract]
public class memberdesignations
{
    [DataMember]
    public string DesigId
    {
        get;  set;
    }
    [DataMember]
    public string DesignationName
    {
        get; set;
    }
}

On searching the forum , i found the cause for it was and explained by Konamiman
here

i would like to know the difference between the two different ways for properties explained by Konamiman

or any other explanation would be appreciated.

Thanks

  • 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-31T18:30:49+00:00Added an answer on May 31, 2026 at 6:30 pm

    The issue is that, as Konamiman said, you are calling a property recursively.

    Let’s say I have a string property “DesignationName”.

    public string DesignationName
    {
      //Some getter to return some data
      //Some setter to set the data
    }
    

    What would you expect it to return? How about returning a hard-coded string _designationName;

    private string _designationName = "someName";
    public string DesignationName
    {
      get {return _designationName;}
      //Some setter to set the data
    }
    

    That works. But what would happen if I had it return itself,instead?

    public string DesignationName
    {
      get {return DesignatioName;}
      //Some setter to set the data
    }
    

    Well, it would keep calling DesignationName, which would keep calling itself again, which would again call DesignationName…and so on. All of this puts data on the stack, and goes on forever until is overruns the allocated space for the stack. Voila, a stackoverflow.

    The reason your last example works is because it is using what is called an ‘autoproperty’, a new feature to .NET 3.0. Basically, behind the scenes, it is creating backing fields for your properties so that this:

    public string DesignationName
    {
      get;
      set;
    }
    

    actually compiles to behave like this:

    private string _designationName = string.Empty;
    public string DesignationName
    {
      get { return _designationName; }
      set { _designationName = value; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Error im getting: An unhandled exception of type 'System.StackOverflowException' occurred in System.Management.dll My callstack:
An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll Make sure you do not
An unhandled exception of type 'System.ArgumentException' occurred in System.Drawing.dll Additional information: Parameter is not
I am getting this error: An unhandled exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll
Uri test = new Uri(http%3A%2F%2F100.100.1.1%3A8080); An unhandled exception of type 'System.UriFormatException' occurred in System.dll
An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll Additional information: 'Provide value on
An unhandled exception of type 'System.TypeInitializationException' occurred in Microsoft.VisualStudio.HostingProcess.Utilities.dll Additional information: The type initializer
My program stops working with this warning An unhandled exception of type 'System.NullReferenceException' occurred
System.TypeInitializationException was unhandled Message=The type initializer for 'SmartHomeworkOrganizer.ViewModels.MainViewModel' threw an exception. Source=SmartHomeworkOrganizer TypeName=SmartHomeworkOrganizer.ViewModels.MainViewModel StackTrace:
Description: An unhandled exception occurred during the execution of the current web request. Please

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.