An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.d


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.d

  1. #1
    Join Date
    Mar 2010
    Posts
    5

    An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.d

    Public Function Delen() As String
    ' vraagt hier voor een volgende kaart.
    Dim getal2 As Integer
    Dim resultaat2 As String
    getal2 = randomGetal2.Next(1, 52)
    If checkGebruikt(getal2) Then
    resultaat2 = CStr(getal2) '& "-" & CStr(type)
    arrayKaarten(tellerArray) = getal2
    tellerArray += 1
    ScoreSpeler = ToevoegenScore(getal2)
    Return resultaat2
    Else
    Delen()
    End If
    End Function

    Here I get "An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll"
    Please HELP

  2. #2
    Join Date
    Feb 2004
    Location
    Longueuil, Québec
    Posts
    577
    I suppose the problem is in the line in bold, so the problem is in randomGetal2, not in the procedure you sent us.

    The first things to look for in StackOverflowException is an endless loop or recursion. Something gets called over and over again with a condition that prevents it from ever returning or exiting.
    Jacques Bourgeois
    JBFI
    http://www3.sympatico.ca/jbfi/homeus.htm

  3. #3
    Join Date
    Mar 2010
    Posts
    5
    in the GDA there is "Dim randomGetal2 As New Random"

  4. #4
    Join Date
    Feb 2004
    Location
    Longueuil, Québec
    Posts
    577
    And what is the GDA exactly? A quick search on the Internet seems to connect it with something in German, and I cannot see what it is used for.

    It is not part of the framework (at least not in the English version). You should contact the people who provided you with that GDA.
    Jacques Bourgeois
    JBFI
    http://www3.sympatico.ca/jbfi/homeus.htm

  5. #5
    Join Date
    Mar 2010
    Posts
    5
    I made it myself, the declaration is Dim randomNumber As New Random and then I put a randomnumber into a variable like getal = randomNumber.next(1,52)

  6. #6
    Join Date
    Feb 2004
    Location
    Longueuil, Québec
    Posts
    577
    Then, the code for your Next method is probably the one that causes the stack overflow. You should post that one.

    Even better, there is a random class in .NET (System.Random). Why don't you used it?
    Jacques Bourgeois
    JBFI
    http://www3.sympatico.ca/jbfi/homeus.htm

  7. #7
    Join Date
    Mar 2010
    Posts
    5
    Dim randomnumber as new random is the random class in .NET, in this function it works:
    Public Function geefEerteKaartenDeler() As String
    Array.Clear(arrayKaarten, 0, arrayKaarten.Length - 1)
    tellerArray = 0
    Dim getal As Integer
    ' Dim type As Integer
    Dim resultaat As String
    getal = randomGetal.Next(1, 52)
    If checkGebruikt(getal) = False Then
    resultaat = CStr(getal) '& "-" & CStr(type)
    arrayKaarten(tellerArray) = getal
    tellerArray += 1
    Return resultaat
    ScoreDeler = ToevoegenScore(getal)

    Else
    geefEerteKaartenDeler()
    'Return "fout"
    End If

    'type = randomGetalType.Next(1, 4)


    End Function

  8. #8
    Join Date
    Feb 2004
    Location
    Longueuil, Québec
    Posts
    577
    OK, I get it, and I see something I had not seen that could trigger the error.

    Public Function Delen() As String
    ' vraagt hier voor een volgende kaart.
    Dim getal2 As Integer
    Dim resultaat2 As String
    getal2 = randomGetal2.Next(1, 52)
    If checkGebruikt(getal2) Then
    resultaat2 = CStr(getal2) '& "-" & CStr(type)
    arrayKaarten(tellerArray) = getal2
    tellerArray += 1
    ScoreSpeler = ToevoegenScore(getal2)
    Return resultaat2
    Else
    Delen()

    End If
    End Function

    Delen calls itself in the Else (recursion). I suppose that the checkGebruikt(getal2) call always returns 0 or False, so you keep going into the Else.

    You have an infinite loop, as I stated in the first post. The line in bold sent me on a wrong track in my evaluation of the problem.
    Jacques Bourgeois
    JBFI
    http://www3.sympatico.ca/jbfi/homeus.htm

  9. #9
    Join Date
    Mar 2010
    Posts
    5
    Thanks , you helped good (y)

Similar Threads

  1. Type Load Exception Problem
    By Govil Manish in forum .NET
    Replies: 1
    Last Post: 09-25-2006, 08:33 AM
  2. Replies: 0
    Last Post: 04-28-2002, 08:07 PM
  3. .NET debugging
    By Angela in forum .NET
    Replies: 8
    Last Post: 12-08-2001, 11:30 AM
  4. What is the UDT?
    By Tahui in forum VB Classic
    Replies: 2
    Last Post: 11-22-2000, 11:24 PM
  5. GetGlyphOutline
    By abeji in forum VB Classic
    Replies: 20
    Last Post: 10-13-2000, 01:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center