Null reference exception when calling parent form from user control in C# WinForms App
<p>I have a peculiar problem in a C# WinForms app in which sever user controls are used within a parent Form.
Here’s the code for the problem user control:</p>

<pre><code>private void LoadMCQuestionScreen(clsQuestion MCQuestion)
{
    ucMultiChoiceQuestion MCQuestionScreen = new  ucMultiChoiceQuestion(MCQuestion, Players, glbintQuestionIndex,
                                                                                glbblTransYesOrNo,
                                                                                lstTransList.ElementAt(glbintQuestionIndex));

   MCQuestionScreen.Parent = this;
   MCQuestionScreen.Show();
    }
</code></pre>

<p>Here’s the block of code for that user control where the crash occurs:</p>

<pre><code>private void QuestionIsAnswered(bool TimeExpired)
{
    //MessageBox.Show("Points: " + glbintPoints.ToString(), "Info...", MessageBoxButtons.OK, MessageBoxIcon.Error);
    //Create a reference to frmMain.

    if (TimeExpired == true)
        glbblAnsweredCorrectly = false;

        frmGame form1 = (frmGame)this.Parent;
        **form1.LoadAnswerResponseScreen(glbblAnsweredCorrectly, glbstrAnsweringPlayer);**
    spTickTock.Stop();
    MCPlayer.Dispose();
    tmrMCTimer.Dispose();
    if (pbQuestionImage.Image != null)
    pbQuestionImage.Image.Dispose();
    this.Dispose();
}
</code></pre>

<p>I get a <code>NullReferenceException</code> on the line in bold – </p>

<blockquote>
  <p>“Object reference not set to an instance of an object.”</p>
</blockquote>

<p>In that line, form1 is null. This method and the user control <code>MCQuestionScreen</code> will have already been disposed when the crash occurs. 
I’ve tried this code at top of the “<code>LoadMCQuestionScreen</code>” method:</p>

<pre><code>foreach (UserControl uctrl in this.Controls)
         uctrl.Dispose();
</code></pre>

<p>That code doesn’t work and after 2 days I still can’t pin down the actual source of the problem.</p>