The problem is your code is recursing. you will need to fix the bug. breaking it up will not help. looking at the stack trace should help find your bug.
Stack Over flow exception for long code in picture box paint.
Hi
I have a long code in picture paint of picture box, so when I run the application, I got a message Stack Over flow exception as per attached photo.
How I can divide the code into two or more subroutine.
The code manly is drawings with many conditions.
The code is in VB.net
Regards,
5 answers
Sort by: Most helpful
-
-
Hany Metry 41 Reputation points
2022-09-13T01:06:21.083+00:00 Hi,
The problem happened during load the program and I don't know how to make stack trace.
-
Bruce (SqlWork.com) 63,741 Reputation points
2022-09-13T17:12:56.567+00:00 in your posted vs image, it is the call stack window.
-
Bruce (SqlWork.com) 63,741 Reputation points
2022-09-19T15:06:01.177+00:00 Stackoverflows are not cause by code length. And breaking up the code (which is typically a good idea for readability and maintenance) will have no effect.
Typically cause is a non terminating recursive call. Review your stack trace.
-
Hany Metry 41 Reputation points
2022-09-20T06:41:42.52+00:00 Hi Bruce
When I try to divide the picturebox1 paint to additional subroutine by writing the following code in the module
Friend e As System.Windows.Forms.PaintEventArgs
Initialization exception happened.
And when I make my program divided into two programs, my problem is solved and I have not stack over flow exception.
So stack over flow exception happened because long code in picture box paint.
Kind Regards,
Hany Metry