An unhandled exception of type 'System.StackOverflowException' occurred in Slate.exe
<p>I'm working on an application in C# and unexpectedly I started getting this exception "An unhandled exception of type 'System.StackOverflowException' occurred in Slate.exe".  </p>

<p>Following are the details of my code.</p>

<p>This is the class in which I have initialized the object of my main class.</p>

<pre><code>public class MenuControls
{
    MainWindow MainWindowObj = new MainWindow(); //This thing is raising Exception.

    public void SaveAs()
    {

        SaveFileDialog SFD = new SaveFileDialog();
        if (SFD.ShowDialog() == System.Windows.Forms.DialogResult.OK)
        {

            String FPath = SFD.FileName;
            StreamWriter SWriter = new StreamWriter(File.Create(FPath));
            SWriter.Write(MainWindowObj.PlayGround.Text);
            SWriter.Dispose();

        }
    }

    public void NewFile()
    {
        MessageBox.Show("You haven't saved your file yet ! Do you want to create new file?", "Something", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);   
    }

    public void OpenFile()
    {
        OpenFileDialog OFD = new OpenFileDialog();

        if (OFD.ShowDialog() == System.Windows.Forms.DialogResult.OK)
        {
            StreamReader SReader = new StreamReader(File.OpenRead(OFD.FileName));
            MainWindowObj.PlayGround.Text = SReader.ReadToEnd();
        }
    }
}
</code></pre>

<p>My main class code. where I have initialized the Object of my <strong>MenuConrols</strong> class.</p>

<pre><code>public partial class MainWindow : Form
{
    public RichTextBox GetBox()
    {
        return PlayGround;
    }
    MenuControls Menu = new MenuControls();
    TextEditor_Preferences Prefrences = new TextEditor_Preferences();

    public int SaveStatus = 0;
    TextEditor_Preferences PreferencesForm = new TextEditor_Preferences();
    public MainWindow()
    {

        InitializeComponent();

    }

    private void MainMenuFile_SaveAs_Click(object sender, EventArgs e)
    {
        Menu.SaveAs();
        SaveStatus = 1;
    }

    private void MainMenuFile_New_Click(object sender, EventArgs e)
    {
        if (SaveStatus == 0 &amp;&amp; PlayGround.Text.Contains("  "))
        {
            Menu.NewFile();
        } else
        {
            PlayGround.Text = "";
        }

    }

    private void MainMenuFile_Open_Click(object sender, EventArgs e)
    {
        Menu.OpenFile();
    }

    private void MainWindow_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.Control &amp;&amp; e.KeyCode.ToString() == "N")
        {
            if (SaveStatus == 0 &amp;&amp; !String.IsNullOrWhiteSpace(PlayGround.Text))
            {
                DialogResult DResult = MessageBox.Show("You haven't saved your file yet ! Do you want to create new file?", "Something", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                if (DResult == DialogResult.Yes)
                {
                    PlayGround.Text = "";
                } else
                {

                }
            }
            else
            {
                PlayGround.Text = "";
            }
        }
        else if (e.Control &amp;&amp; e.KeyCode.ToString() == "O")
        {
            Menu.OpenFile();
        }
        else if (e.Control &amp;&amp; e.KeyCode.ToString() == "S")
        {
            Menu.SaveAs();
            SaveStatus = 1;
        }
    }
    private void MainMenuEdit_Preferences_Click(object sender, EventArgs e)
    {
        PreferencesForm.ShowDialog();
    }

}
</code></pre>

<p>Please suggest me a solution. <strong>If I'm missing something or the question is not asked properly, please let me know explicitly.</strong>
Thanks.</p>