Stack Overflow Exception

  • Thread starter Thread starter Gorge Bush
  • Start date Start date
G

Gorge Bush

Hi there,
all was going well with my first C# project until now as I am
getting a Stack Overflow exception. I haven't seen one of those since DOS
programming days and back then all you did was up the stack size. How do I
get around this in .Net?
 
Hi,

This problem exist in all environment I can think of, if you write a
recursive method incorrectly you will get it, like

void Foo( parameters )
{
Foo( .... );
}

do u have any recursive method?

Cheers,
 
Gorge Bush said:
all was going well with my first C# project until now as I am
getting a Stack Overflow exception. I haven't seen one of those since DOS
programming days and back then all you did was up the stack size. How do I
get around this in .Net?

Chances are it's because you've got a recursive property, eg:

string Foo
{
get { return Foo; }
}

I suggest you track down the last call you can make before the
overflow, and hopefully it'll be obvious.
 
Gorge,

Chances are this is the result of some sort infinite loop/recursion.
Can you post the code that does it?
 
Found it! In the code for setting a property, I was refering to the
property name instead of the member variable.

Thanks for the speedy replies.
 
you probably have a recursive call that doesn't end. look at the call stack
and identify which method, operator overload, or most likely property is the
offender.
 
Can you trace the overflow to a specific call? I've seen the good old stack
overflow a couple times in my .Net experience, and it's usually been because
of an infinite loop or a local variable having the same name as a property.

Give us a code sample and we may be able to spot it for you.

-James
 
Hi

Good to know you solve it,

Try to use the recommended naming convention as this will decrease the
likely of this to happen again.

cheers,
 
Back
Top