title: An unhandled exception of type 'System.ObjectDisposedException' occurred in System.dll
body: <p>In my project, when I run it by debugging, after some times, it suddenly has been crashed. It didnt happen in any special time or after specific period time. It crashed itself and I dont know why?!</p>
  
  <p>I got this message:</p>
  
  <pre><code>An unhandled exception of type 'System.ObjectDisposedException' occurred in System.dll
  Additional information: Cannot access a disposed object.
  </code></pre>
  
  <p>and its the picture of that, for more information...</p>
  
  <p><img src="https://i.stack.imgur.com/Lxe1w.jpg" alt="enter image description here"></p>
  
  <p>Im working with vs 2013 and C# win form...</p>
  
  <p>Its my simple code :</p>
  
  <pre><code>private void btnConnect_Click(object sender, EventArgs e)
      {
          Result = socketComponent.tcpConnect(Host, int.Parse(Port));
          if (Result == 0)
              MessageBox.Show("Connected"); 
      }
  
  private void btnDisconnect_Click(object sender, EventArgs e)
  {
      if (socketComponent != null)
      {
          socketComponent.tcpDisconnect();
  
          socketComponent.Dispose();
          MessageBox.Show("DisConnected"); 
      }
  
  }
  </code></pre>
  
  <p>It happened suddenly after click On btnDisconnect. maybe after second click or more ...</p>