I am working on a Windows Application Development in c# language. I have a template form => Masterpage which is inherited by all my other forms.
It has menustrip to open all other forms as well:
my error reads:
System.StackOverflowException
HResult=0x800703E9
Source=<Cannot evaluate the exception source>
StackTrace:
<Cannot evaluate the exception stack trace>
my Masterpage code is:
namespace WindowsProject
{
public partial class Masterpage : Form
{
BookEditor bookE;
StudentEditor studentE;
ViewBorrowedBooks viewB;
IssueBook issueBook;
public Masterpage()
{
InitializeComponent();
bookE = new BookEditor();
studentE = new StudentEditor();
viewB = new ViewBorrowedBooks();
issueBook = new IssueBook();
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void showForm(Form f)
{
bookE.Hide();
studentE.Hide();
viewB.Hide();
issueBook.Hide();
this.Hide();
f.Show();
}
private void booksToolStripMenuItem_Click(object sender, EventArgs e)
{
showForm(bookE);
}
private void studentsToolStripMenuItem_Click(object sender, EventArgs e)
{
showForm(studentE);
}
private void viewBorrowedBooksToolStripMenuItem_Click(object sender, EventArgs e)
{
showForm(viewB);
}
private void issueBookToolStripMenuItem_Click(object sender, EventArgs e)
{
showForm(issueBook);
}
}
}
all my other forms inherits from Masterpage
BookEditor,StudentEditorand others inherit fromMaterHomePage?StackOverflowException. Why do you need to create them in the constructor of theMasterPage?