StackOverflowException

  • Thread starter Thread starter A. Gaubatz
  • Start date Start date
A

A. Gaubatz

When I run my program, I get this error: "An unhandled exception of type
'System.StackOverflowException' occurred in mscorlib.dll". I have
isolated it to a single subroutine which involves several loops(they are
For loops, so they would not be infinitly repeating) and random numbers,
as well as manipulating strings. What exactly does this error mean. The
help file is not very clear (or maybe to complicated for me)

Thanks
 
A. Gaubatz said:
When I run my program, I get this error: "An unhandled exception of
type 'System.StackOverflowException' occurred in mscorlib.dll". I
have isolated it to a single subroutine which involves several
loops(they are For loops, so they would not be infinitly repeating)
and random numbers, as well as manipulating strings. What exactly
does this error mean. The help file is not very clear (or maybe to
complicated for me)


It means that the stack is full. Too many local variables and/or nested
procedure calls. When the excpetion occurs, have a look at the callstack
window to find out what causes the problem.


Armin
 
Sorry to bother everyone. I managed to fix my problem. I was under the
assumption that this had something to do with too many strings open at
once, so I was not looking for the real problem (an infinite loop *not*
from a loop command).

Sorry again
 
I usually get this error when I have made a mistake in a "property"
function. For example:



Public Property SomeValue As Integer

Get
Return m_Value
End Get

Set ( ByVal theValue As Integer )
SomeValue = theValue
End Set

End Property



As you can see in the above, "Set", is setting the property, which is
setting the property, which is setting the property, etc. and will never
terminate (until the stack overflows). I should have written obviously:

Set (ByVal theValue As Integer)
m_Value = theValue
End Set



Anyway this is just an example of a stack overflow from a simple coding
error. Perhaps you could post your routine?
 
In my experience, the call stack usually shows something like this:


Foo ( x )
Foo ( x )
Foo ( x )
Foo ( x )
Foo ( x )
Foo ( x )
Foo ( x )
Foo ( x )
Foo ( x )
Foo ( x )
Foo ( x )
Foo ( x )
..... ad nauseum.......
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top