I am writing an application in C# which looks like this:
public partial class MainForm : Form
{
WICForm Frm = new WICForm();
public MainForm(){}
}
Where _MainForm_
and _WICForm_
are two different forms in the same application. But when I run the application I get the above error when creating a new instance Frm
of WICForm
. What could be the reason?
Presumably, you are creating a new instance of MainForm
in the constructor in WICForm
(or from some code called from within it).
That way the MainForm
and WICForm
classes are calling and constructing new instances of each other recursively, which will result in a stack overflow exception.
Tip: Put a breakpoint on the line containing new WICForm();
(place the cursor on that line and press F9
). When you run the code in debug mode now, you can step into that method to see what it does.