Odd Exception Trying To Load Form

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

I am back yet again :)

I am encountering an Exception that has me scratching my
head. I have two forms. Form A launches Form B in response
to the user clicking a button. The Constructor for Form B
takes 5 parameters but none of them complicated ( three
short strings and two booleans ). Form B does have several
controls on it (around 148 when you count in group boxes,
labes and menus). However, I have forms with far more that
load without a problem.

The constructor simply sets 5 class values and of corse
the required InitializeComponent() call is there.
Everytime I attempt to load Form B I get the following
Exception

System.StackOverflowException: Exception of type
System.StackOverflowException was thrown

I can't figure out what the problem may be. If anyone has
any ideas I would greatly appreciate it. Thanks!

Dan
 
Dan said:
Everytime I attempt to load Form B I get the following
Exception

System.StackOverflowException: Exception of type
System.StackOverflowException was thrown

Check the call stack, most likely a function is calling itself repeatedly.
 
does the error happen when you call an empty constructor on the form? this
will elminate your parameters as the possible source

i.e. make a default

FormA()
{
InitializeComponent();
}

i'd also check to see if you are adding controls in a loop, that would cause
an error such as you are seeing.

just a couple of thoughts :)
 
Tam and Michael,

Thanks for your quick respondes to my post. You put me in
the right direction and I was able to solve the problem.
It turns out that I was trying to pass in a null value on
one of my parameters. Once I fixed that it was running
great. Thanks again!

Dan
 
If passing a null param gives you a stack overflow then something still needs to be fixed.
 
Back
Top