title: Cannot access a disposed object - How to fix?
body: <p>In a VB.NET WinForms project, I get an exception</p>
  
  <blockquote>
    <p>Cannot access a disposed of object</p>
  </blockquote>
  
  <p>when closing a form. It occurs very rarely and I cannot recreate it on demand. The stack trace looks like this:</p>
  
  <pre><code>Cannot access a disposed object. Object name: 'dbiSchedule'.
    at System.Windows.Forms.Control.CreateHandle()
    at System.Windows.Forms.Control.get_Handle()
    at System.Windows.Forms.Control.PointToScreen(Point p)
    at Dbi.WinControl.Schedule.dbiSchedule.a(Boolean A_0)
    at Dbi.WinControl.Schedule.dbiSchedule.a(Object A_0, EventArgs A_1)
    at System.Windows.Forms.Timer.OnTick(EventArgs e)
    at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message&amp; m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  </code></pre>
  
  <p>The dbiSchedule is a schedule control from Dbi-tech. There is a timer on the form that updates the schedule on the screen every few minutes.</p>
  
  <p>Any ideas what is causing the exception and how I might go about fixing it? or even just being able to recreate it on demand?</p>
  
  <hr>
  
  <p>Hej! Thanks for all the answers. We do stop the Timer on the FormClosing event and we do check the IsDisposed property on the schedule component before using it in the Timer Tick event but it doesn't help.</p>
  
  <p>It's a really annoying problem because if someone did come up with a solution that worked - I wouldn't be able to confirm the solution because I cannot recreate the problem manually.</p>