I can not catch this error (StackOverFlowException)

2

In a project that I am doing, I have this error that I can not locate. It is a main form with a TabControl that loads other forms within each of its tabs.  Did something similar happen to someone? Any idea that you can generate it?

-Edito:

Thanks for the reply. He repeats these three lines to me again and again (I also edit the image):

  

MdiTabControl.dll! MdiTabControl.TabControl.TabPageCollection.set_IndexOf (MdiTabControl.TabPage   TabPage, Integer value) Line 287 + 0xd Bytes

     

MdiTabControl.dll! MdiTabControl.TabControl.SelectItem (MdiTabControl.TabPage   TabPage) Line 1607 + 0x22 Bytes MdiTabControl.dll!

     

MdiTabControl.TabControl.ArrangeItems () Line 1532 + 0x46 Bytes

I'm not sure you're trying to control exactly. It occurs normally when changing screens or minimizing, in a very random way (It does not always occur). Any ideas that could produce it, could changing the control by VS itself solve it?

EDIT2: These are the only code lines where the MDItabcontrol intervenes:

Public Sub openForm(ByRef frm As Form)
    Try

    TabControl1.Visible = True
        TabControl1.TabPages.Add(frm)
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
End Sub

 Private Sub resizeform(ByVal sender As System.Object)
    Try
    TabControl1.Width = sender.Size.Width - 20
        TabControl1.Height = sender.Size.Height - ToolStrip1.Height - TabControl1.TabHeight
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
End Sub
Private Sub Form1_SizeChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
    If Me.Visible Then
        resizeform(sender)
    End If
End Sub
Public Sub repintarfondo()
    Try
        If TabControl1.TabPages.Count = 1 Then
            TabControl1.Visible = False
        End If
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
End Sub

As you can see, I do not have any events for those shown in the image. That's why he misses me so much.

Greetings and thanks for the help.

    
asked by ZaZZ 02.06.2016 в 11:13
source

3 answers

1

It's an overflow error in the call stack.

When the exception is raised, look at the call stack window.

This error occurs when recursive operations occur. Either a method is calling itself recursively or is calling a method that in turn calls the initial method.

This causes the application to enter an infinite loop making calls to this method until it reaches the limit of exceeding the limit of the call stack and the error occurs.

As I was saying, check the call stack window at the moment when the error occurs and you will see the method (s) that are causing the problem.

    
answered by 02.06.2016 в 11:33
1

StackOverflow is the typical infinite recursion error. In your case, there is a clear suspicion

Private Sub Form1_SizeChanged....
    .....
    resizeform(sender)

You are apparently changing the size of a form in the resize event of that form. It smells infinitely recursive ....

    
answered by 02.08.2016 в 12:17
0

StackOverflowException is an exception that can not be controlled unless it is launched by the code you are programming. The most advisable thing for these cases is to verify the execution stack since it typically happens when there are loops of infinite calls, either in indirect or direct recursive functions. As I see the problem is in the control MdiTabControl, what you could do is download the code of this, which is in codeproject and use it as a reference to evaluate in greater detail what are the factors that lead to the exception

    
answered by 31.10.2016 в 17:16