locked
System.ObjectDisposedException RRS feed

  • Question

  • Hi All,

    I have a user control(name: Header) in which I have a timer which runs every 5 seconds.

    In this I am setting the image of a picture box based on some flags and I want to set label text with the current time. This user control is placed on a form on which another timer is ticking which in turn calls a background thread.

    Everything was working fine till I was handling image in the user control but now I want to show the current time in label also which is causing the problem. If I stay on the form for some time and do nothing then also the application crashes giving the message:

    System.ObjectDisposedException
       at Microsoft.AGL.Common.MISC.HandleAr(PAL_ERROR ar)
       at System.Windows.Forms.Control.get_Text()
       at System.Windows.Forms.Control.set_Text(String value)
       at Fernwaerme.PL.Controls.Header.GetElapsedTime()
       at Fernwaerme.PL.Controls.Header.headerTimer_Tick(Object sender, EventArgs e)
       at System.Windows.Forms.Timer._WnProc(WM wm, Int32 wParam, Int32 lParam)
       at System.Windows.Forms.ApplicationThreadContext._InternalContextMessages(WM wm, Int32 wParam, Int32 lParam)
       at Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)
       at System.Windows.Forms.Application.Run(Form fm)
       at Fernwaerme.PL.frmProgramFlow.Main()

    Please help on this!!!!
    Dipti Chawla
    Thursday, November 17, 2011 8:40 AM

All replies

  • One of two things has happened: either the object's Dispose() method was called or the object was disposed by the garbage collector.

    Either way, you'll have to post your code to determine which it is.

    -PaulH

    Thursday, November 17, 2011 7:12 PM
  • i have the same problem

    it happens randomly (happens sometimes), the code is fine it was working fine on windows mobile 5.2/6/6.1 but on GEN2WAVE device with WM6.5 it start giving us this problem

    System.ObjectDisposedException was unhandled
      Message=""
      ObjectName=""
      StackTrace:
           at Microsoft.AGL.Common.MISC.HandleAr(PAL_ERROR ar)
           at System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit)
           at System.Windows.Forms.PictureBox.OnPaint(PaintEventArgs e)
           at System.Windows.Forms.Control.WnProc(WM wm, Int32 wParam, Int32 lParam)
           at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
           at Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)
           at System.Windows.Forms.Application.Run(Form fm)
           at PDAAcc2007.FRM_Startup.Main()
      InnerException:

    i digged into and i noticed that the problem happens only in forms that we used picturebox with image bitmap as a button, the picture box are static they have only click event

    and help here

    Wednesday, November 21, 2012 9:17 AM