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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:43:47+00:00 2026-06-01T14:43:47+00:00

This is my property on my code : public KPage Padre { get {

  • 0

This is my property on my code :

public KPage Padre
{
    get
    {
        if (k_oPagina.father != null)
        {
            this.Padre = new KPage((int)k_oPagina.father);
        }
        else
        {
            this.Padre = null;
        }

        return this.Padre;
    }
    set { }
}

but it says :

An unhandled exception of type ‘System.StackOverflowException’ occurred in App_Code.rhj3qeaw.dll

Why? How can I fix it?

EDIT

After correct the code, this is my actual code :

private KPage PadreInterno;
public KPage Padre
{
    get
    {
        if (PadreInterno == null)
        {
            if (paginaDB.father != null)
            {
                PadreInterno = new KPage((int)paginaDB.father);
            }
            else
            {
                PadreInterno= null;
            }
        }

        return PadreInterno;
    }
}

What do you think about?

  • 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-01T14:43:49+00:00Added an answer on June 1, 2026 at 2:43 pm

    The property is calling itself… usually properties call underlying fields:

       public KPage Padre
       {
           get
           {
               if (k_oPagina.father != null)
               {
                   _padre = new KPage((int)k_oPagina.father);
               }
               else
               {
                   _padre = null;
               }
    
               return _padre;
           }
           set { }
       }
    
       private KPage _padre;
    

    Your old code was recursively calling the get of the Padre property, hence the exception.

    If your code only “gets” and doesn’t need to store the value, you could also get rid of the backing field entirely:

       public KPage Padre
       {
           get
           {
               return k_oPagina.father != null
                  ? new KPage((int)k_oPagina.father)
                  : (KPage)null;
           }
       }
    

    That said, I’d put this in a method.

    This is also the same issue as the one you asked a couple of days ago:

    An unhandled exception of type 'System.StackOverflowException' occurred

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

Sidebar

Related Questions

Given this code: public class Car { public virtual int CarId { get; set;
I have a property which looks like this. public int NumberOfElephants { get; set;
I happened to read this line of code: public MyArray this [int index]{ get{
I get the memberOf property for my user using this code: DirectorySearcher search =
I have the following custom property in my code: public Dictionary<int, string> ServiceIdList {
I would like to try this code: public struct Direction { private int _azimuth;
I have a ObservableCollection property and also this property public ListCollectionView ListView { get
So here is the simple code: [System.ComponentModel.DefaultValue(true)] public bool AnyValue { get; set; }
I have the following code: public class OMyObject { public int Id { get;
I have this property, which is working fine: public IEnumerable<IGrouping<MessageType, Message>> MessageGroups { get

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.