Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

An unhandled exception of type 'System.StackOverflowException'

Status
Not open for further replies.

MikeParc

Technical User
Jan 13, 2003
15
DE
Hi,

I tried to compile my vb.NET program and it displays this error:

An unhandled exception of type 'System.StackOverflowException' occurred in Unknown Module.

Fatal stack overflow error.


If I try to see the error, it says:

There is no source code available for the current location

So, how can I repair the error if I can't see it ?

Thanx for help...

Mike
 
Look for some runaway recursion. You may have to put in some breakpoints and step through. Also, be aware that events for controls can fire during control initialization, unlike VB6. Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
hi,

i checked for breakpoints but there weren't any...but could you tell me what 'runaway recursion" is ???
And what's that "cantrols can fire" ???

Thanx for help.

Mike
 
You have to set the breakpoints. Runaway recursion happens when an event or procedure calls itself, directly or indirectly, with no mechanism in place to halt it.

"Controls can fire" events means "trigger", cause to happen etc etc. For example, if you have a label with a Text property defined at design-time, a TextChanged event will occur (be fired) when the "InitializeComponent" generated by the Windows Form Designer moves the "Design-Time" text into the Text property of the label. This did not happen in VB6.

Check all your events and determine if they can inturn cause other events to occur that could in turn cause the original event to occur again.

To check for a recursion in a procedure/Event, try the following code in suspected procedures.
Static blnBusy as Boolean
if blnBusy then
Msgbox "recursion at procedurename"
end if
blnBusy = true
..........whatever
blnBusy = false ' must be executed before any exit
End Sub/Function

When you get the Stack Overflow, check the Stack Trace to see if any of the calls in the list are from your code and put a breakpoint in that code so you can step through it in Debug Mode. Be sure that Build / Configuration Manager / Active Solution Configuration is set for "Debug". Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Mike,

You need to put the breakpoints in yourself for the code that is executing.

Recursion is code calling itself. For example

Public Sub AddTo100(i As Integer)
Do until i = 100
AddTo100(i+1)
Loop
End Sub

Silly example but illustrates what recursion is.

Runaway recursion is where is is doing it so many times that the stack (a holding bay in memory dealt with in a LIFO manner) runs out of places to hold the intermediate calculations.

Basically what you've got is a loop of somekind going on that's got so big your PC runs out of memory.

Craig
 
Well, I did as you said but

FIRST:

I set a breakpoint at the Form1_Load function and it didn't arrive...

SECOND:

There is nothing in the Stack trace....

AND:

It's an unknown Module...


Thanx for help...

Mike
 
well I found the Error...it's the line:

Dim mpMedia As MediaPlayer.MediaPlayer

What'S wring with it ???

Mike
 
ok...false alarm....it isn't

Dim mpMedia As MediaPlayer.MediaPlayer

IT WAS THE SECOND FORM....

But why ?? I need to have a second form...

Mike

 
Mike,

As before, you have a very large process running that is overloading the stack. Breakpoint the second form.

Craig
 
It's alright now...I found the error in the second form...

Thanx for your help..

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top