title: getting System.ObjectDisposedException: Cannot access a disposed object.Modeless Dialogs in C#
body: <p>I'd like to generate a modeless dialog box, whenever I close the box and want to open it again I am getting an error saying  </p>
  
  <pre><code>System.ObjectDisposedException: Cannot access a disposed object.
  Object name: 'TransactionHistoryDialog'.
     at System.Windows.Forms.Control.CreateHandle()
  </code></pre>
  
  <p>here is my code for creating the modeless dialogbox </p>
  
  <pre><code>public partial class TransactionHistoryDialog : Form
  {
      private static TransactionHistoryDialog instance;
  
      private TransactionHistoryDialog()
      {
          InitializeComponent();
      }
  
      public static TransactionHistoryDialog CreateForm() 
      {
          if (instance == null) 
          {
              instance = new TransactionHistoryDialog();
          }
  
          return instance;
      }
  
      private void TransactionHistoryDialog_FormClosing(object sender, FormClosingEventArgs e)
      {
          instance = null;           
      }
  
      private void buttonClose_Click(object sender, EventArgs e)
      {
          instance = null; 
  
      }
  
  
      private void buttonTransactionHistoryClose_Click(object sender, EventArgs e)
      {
          this.Dispose();
      }
  
  
  }
  </code></pre>
  
  <p>then in my main form whenever the transactionHistory button is clicked transaction dialog shows up : here is my code for event of clicking transaction button </p>
  
  <pre><code> private void buttonTransferHistory_Click(object sender, EventArgs e)
      {
          TransactionHistoryDialog transactionHistory = TransactionHistoryDialog.CreateForm();
          transactionHistory.updateTextBox();
          transactionHistory.Show();     
  
      }
  </code></pre>
  
  <p>I have search a lot, but could not find where the problem is. can any one please give me some hints ?</p>