Results 1 to 10 of 10

Thread: [2005] 'System.StackOverflowException'

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    406

    [2005] 'System.StackOverflowException'

    Good afternoon!

    I have been receiving the below exception:

    An unhandled exception of type 'System.StackOverflowException' occurred in System.Data.dll

    My app has various text boxes that allows a user to enter certain criteria for fields to build a filter property for a datagridview.

    Whenever the user enters more than 300 or so items (could be character limit, not sure), the above error occurs when they attempt to receive the records. Or maybe a limit on the amount of records it can return.

    I can't seem to Catch the exception, and do the app just closes.

    Looking at the 'View Detail' only shows the above exception message.

    Any ideas?

    Thanks!
    Last edited by jeffcravener; Dec 2nd, 2008 at 01:41 PM.

  2. #2
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: [2005] 'System.StackOverflowException'

    the code i see looks correct.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    406

    Re: [2005] 'System.StackOverflowException'

    Sorry, didn't post the code because it doesn't appear to be a code issue, so much as a DLL issue. Liek some kind of limit. Need to know of a way to catch the error when it is from the DLL.

    Here is the code it appears it is happening at (.NET is not pointing to any code when the error occurs, but when commented out, the rest of the code works)

    Code:
            With dvOrigSRs 
                .Table = dsCMT.Tables(My.Settings.CMTSTNDRDR).Copy
                .RowFilter = TFNFilter
                .Sort = CreateSortString()
            End With

  4. #4
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2005] 'System.StackOverflowException'

    How does CreateSortString look?
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    406

    Re: [2005] 'System.StackOverflowException'

    This is createsortstring:

    Code:
    Private Function CreateSortString() As String
            Dim l As Button
            Dim s As String = ""
    
            For Each l In ButtonSorts
                If l.Text <> "NS" Then
                    If l.Text = "S^" Then
                        s = "ASC"
                    Else
                        s = "DESC"
                    End If
                    Select Case l.Name
                        Case "butSortTFN"
                            s = "[TFN] " & s
                        Case "butSortMP"
                            s = "[M/P] " & s
                        Case "butSortAPPL"
                            s = "[APPL] " & s
                        Case "butSortPROD"
                            s = "[PROD] " & s
                        Case "butSortCNC"
                            s = "[CL/NCL] " & s
                        Case "butSortALTOFF"
                            s = "[ALT OFF] " & s
                        Case "butSortIBP"
                            s = "[IBP] " & s
                        Case "butSortOBP"
                            s = "[OBP] " & s
                        Case "butSortXFER"
                            s = "[XFER] " & s
                    End Select
                End If
            Next
    
            If s = "" Then
                s = "[Sequence] " & "ASC"
            Else
                s = s & ",[Sequence] " & "ASC"
            End If
    
    
            Return s
    
        End Function
    But its def not that code, as when i am testing the condition limit, i don't sort any columns.

    Here is the code used to create the conditions:

    Code:
      Private Sub RetrieveResults()
            Dim tLU As String = ""
            Dim LookUp As String = ""
    
            UpdateStatus("Creating lookup statement", True)
    
            LookUpSub(tLU, "TFN", txtTFNS.Lines)
            If tLU <> "" Then LookUp = tLU
    
            LookUpSub(tLU, "M/P", txtMP.Lines)
            If tLU <> "" Then
                If LookUp = "" Then
                    LookUp = tLU
                Else
                    LookUp = LookUp & " AND " & tLU
                End If
            End If
    
            LookUpSub(tLU, "APPL", txtAPP.Lines)
            If tLU <> "" Then
                If LookUp = "" Then
                    LookUp = tLU
                Else
                    LookUp = LookUp & " AND " & tLU
                End If
            End If
    
            LookUpSub(tLU, "PROD", txtPROD.Lines)
            If tLU <> "" Then
                If LookUp = "" Then
                    LookUp = tLU
                Else
                    LookUp = LookUp & " AND " & tLU
                End If
            End If
    
            LookUpSub(tLU, "CL/NCL", txtCNC.Lines)
            If tLU <> "" Then
                If LookUp = "" Then
                    LookUp = tLU
                Else
                    LookUp = LookUp & " AND " & tLU
                End If
            End If
    
            LookUpSub(tLU, "ALT OFF", txtALTOFF.Lines)
            If tLU <> "" Then
                If LookUp = "" Then
                    LookUp = tLU
                Else
                    LookUp = LookUp & " AND " & tLU
                End If
            End If
    
            LookUpSub(tLU, "IBP", txtIBPs.Lines)
            If tLU <> "" Then
                If LookUp = "" Then
                    LookUp = tLU
                Else
                    LookUp = LookUp & " AND " & tLU
                End If
            End If
    
            LookUpSub(tLU, "OBP", txtOBPs.Lines)
            If tLU <> "" Then
                If LookUp = "" Then
                    LookUp = tLU
                Else
                    LookUp = LookUp & " AND " & tLU
                End If
            End If
    
            LookUpSub(tLU, "XFER", txtXFERs.Lines)
            If tLU <> "" Then
                If LookUp = "" Then
                    LookUp = tLU
                Else
                    LookUp = LookUp & " AND " & tLU
                End If
            End If
    
            If LookUp = "" Then
                MessageBox.Show("You must choose at least one field to filter by. Thanks.", "No Filter Values Selected", MessageBoxButtons.OK, MessageBoxIcon.Information)
                UpdateStatus("Ready")
                Exit Sub
            End If
    
            LoadTFNorDNIS(LookUp)
    
        End Sub
        Private Function ConditionCount() As Long
            Return txtTFNS.Lines.Length + txtMP.Lines.Length + txtAPP.Lines.Length + _
                   txtPROD.Lines.Length + txtCNC.Lines.Length + txtALTOFF.Lines.Length + _
                   txtIBPs.Lines.Length + txtOBPs.Lines.Length + txtXFERs.Lines.Length
        End Function
        Private Sub LookUpSub(ByRef FilterText As String, ByVal FieldName As String, ByVal TextBoxLines() As String)
            Dim i As Integer
    
            FilterText = ""
            If TextBoxLines.Length > 0 Then
                For i = 0 To TextBoxLines.Length - 1
                    If FieldName = "TFN" And (TextBoxLines(i) <> "(Blanks)") And (TextBoxLines(i) <> "(No Blanks)") Then TrimTFNChars(TextBoxLines(i))
                    If FilterText.Contains(TextBoxLines(i)) = False Then
                        If TextBoxLines(i) = "(Blanks)" Then
                            If FilterText = "" Then
                                FilterText = "[" & FieldName & "] IS NULL"
                            Else
                                FilterText = FilterText & " OR [" & FieldName & "] IS NULL"
                            End If
                        ElseIf TextBoxLines(i) = "(No Blanks)" Then
                            If FilterText = "" Then
                                FilterText = "[" & FieldName & "] IS NOT NULL"
                            Else
                                FilterText = FilterText & " OR [" & FieldName & "] IS NOT NULL"
                            End If
                        Else
                            If FilterText = "" Then
                                FilterText = "[" & FieldName & "] = '" & TextBoxLines(i) & "'"
                            Else
                                FilterText = FilterText & " OR [" & FieldName & "] = '" & TextBoxLines(i) & "'"
                            End If
                        End If
                    End If
                Next
                FilterText = "(" & FilterText & ")"
            End If
        End Sub
    Currently using the condition count, against 370, as a workaround to try to avoid the error. But if it is a character based limit, then it could still error out depending on what conditions the user puts.

  6. #6
    Addicted Member
    Join Date
    Sep 2008
    Location
    Jacksonville, Florida
    Posts
    147

    Re: [2005] 'System.StackOverflowException'

    And when you hit the stack overflowexception in the debugger, what does the function list look like on the stack trace? (Call Stack window) While the exception is up -> Debug -> Windows -> Call Stack.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    406

    Re: [2005] 'System.StackOverflowException'

    Like this:
    > [External Code]

  8. #8
    Addicted Member
    Join Date
    Sep 2008
    Location
    Jacksonville, Florida
    Posts
    147

    Re: [2005] 'System.StackOverflowException'

    If all the stack trace says is that, then either your code is not loading into the debugger or the exception is happening in an external dll you are referencing. Check the internal Exception property of the exception perhaps?

  9. #9
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: [2005] 'System.StackOverflowException'

    Normally, this type of an error occurs when you have created an endless recursive call. Each function call will stick the current state onto the stack and get a little stack space, as needed. Thus, if you end up in an infinite recursion, then each iteration will stick more stuff onto the stack until the stack overflows. I would expect that the same thing is possible with limitted recursion, but I have never seen it. Unfortunately, the problem is being caused externally.

    In the original snippet, why are you calling .Copy on the table?
    My usual boring signature: Nothing

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    406

    Re: [2005] 'System.StackOverflowException'

    Calling .Copy because i don't want changes made to the datagridview to actually change the working copy of the database. So i have a copy created for the DV.

    But when i place messageboxes before and after the .RowFilter line of code, i only see the first messagebox, then it crashes.

    With dvOrigSRs 'dv
    .Table = dsCMT.Tables(My.Settings.CMTSTNDRDR).Copy
    MessageBox.Show("BOB")
    .RowFilter = TFNFilter
    MessageBox.Show("FRED")
    .Sort = CreateSortString()
    End With

    So, it is def related to the filter string having too many characters/conditions. But irritating that i can't put a 'catch' to catch it.

    I can't see where an endless recursive call would come into play here since it is a SQL liek statement going to the RowFilter property.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width