PictureBox1 GDI+ error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?QWxpY2U=?=

    #1

    PictureBox1 GDI+ error

    Sorry for reposting here but I apparantly managed to pick the wrong
    discussion group earlier. Here's my story:

    Hi all,

    I am developping a simple application that displays an animated weather .gif
    in a picturebox. Besides the picturebox there are only a few labels on the
    form. The form is called from a module.

    The .gif is loaded from the internet via
    PictureBox1.Ima geLocation = [URL string to image]
    and is reloaded every 10 minutes.

    Things that I observe:
    1) The application NEVER crashes in the IDE running on Windows XP
    2) The compiled application DOES crash on all 3 different XP test computers,
    including the one that hosts VS 2005 and that is used to develop the app.
    Often it crashes repeatedly immediately after starting the program, often
    only after a few hours. The program never was able to run for 24 hours.
    3) The application NEVER crashes on Windows Vista.

    If I deactivate the part that loads the image, the program never crashes, so
    I am sure the picturebox is the culprit.

    After some Googling on this subject, I tried to replace
    PictureBox1.Ima geLocation = [URL string to image]
    by
    Dim WebClient As New System.Net.WebC lient
    Dim bytes() As Byte = WebClient.Downl oadData([URL string to image])
    Dim Stream As New IO.MemoryStream (bytes)
    PictureBox1.Ima ge = New System.Drawing. Bitmap(Stream)

    Unfortunately, that didn't improve much. I do notice, however, that when
    adding
    Stream.Close
    the application DOES crash in the IDE, however the error ignores the
    Try..Catch in the Sub that contains the above and is only caught by the Catch
    in the Module that loads the Form. If I remove Stream.Close, the app does
    crash on XP (but not in the IDE) and not on Vista, just as before.

    If the program crashes, the familiar GDI+ error box is shown, without really
    much help on what is going on. Most of the times, the PictureBox is replaced
    by a white background and a red cross and eventually the labels on the form
    are replaced by those red crosses as well. Sometimes it starts with crossing
    the labels instead, however. Often even the buttons on the GDI+ error window
    get these red crosses(?!).

    Does anyone know what is going on here? Thanks in advance!




  • =?Utf-8?B?QWxpY2U=?=

    #2
    RE: PictureBox1 GDI+ error

    Hmm, nobody an idea?

    This is the message I get:

    ************** Exception Text **************
    System.Runtime. InteropServices .ExternalExcept ion: A generic error occurred
    in GDI+.
    at System.Drawing. Image.SelectAct iveFrame(FrameD imension dimension, Int32
    frameIndex)
    at System.Drawing. ImageAnimator.I mageInfo.Update Frame()
    at System.Drawing. ImageAnimator.U pdateFrames()
    at System.Windows. Forms.Label.OnP aint(PaintEvent Args e)
    at System.Windows. Forms.Control.P aintWithErrorHa ndling(PaintEve ntArgs e,
    Int16 layer, Boolean disposeEventArg s)
    at System.Windows. Forms.Control.W mPaint(Message& m)
    at System.Windows. Forms.Control.W ndProc(Message& m)
    at System.Windows. Forms.Label.Wnd Proc(Message& m)
    at System.Windows. Forms.Control.C ontrolNativeWin dow.OnMessage(M essage& m)
    at System.Windows. Forms.Control.C ontrolNativeWin dow.WndProc(Mes sage& m)
    at System.Windows. Forms.NativeWin dow.Callback(In tPtr hWnd, Int32 msg,
    IntPtr wparam, IntPtr lparam)


    Is somebody able to 'read' and translate this? I have a Label1 on top of (in
    front of) the Picturebox1. Is that the problem? Could this be caused by a
    repaint problem of the label?

    Again: it does not happen in the IDE and not on Vista, only on the XP
    computers.


    Comment

    • Mythran

      #3
      Re: PictureBox1 GDI+ error



      "Alice" <Alice@discussi ons.microsoft.c omwrote in message
      news:022B5E0C-DF87-4FF8-B48A-15652CA3A1A7@mi crosoft.com...
      Hmm, nobody an idea?
      >
      This is the message I get:
      >
      ************** Exception Text **************
      System.Runtime. InteropServices .ExternalExcept ion: A generic error occurred
      in GDI+.
      at System.Drawing. Image.SelectAct iveFrame(FrameD imension dimension,
      Int32
      frameIndex)
      at System.Drawing. ImageAnimator.I mageInfo.Update Frame()
      at System.Drawing. ImageAnimator.U pdateFrames()
      at System.Windows. Forms.Label.OnP aint(PaintEvent Args e)
      at System.Windows. Forms.Control.P aintWithErrorHa ndling(PaintEve ntArgs e,
      Int16 layer, Boolean disposeEventArg s)
      at System.Windows. Forms.Control.W mPaint(Message& m)
      at System.Windows. Forms.Control.W ndProc(Message& m)
      at System.Windows. Forms.Label.Wnd Proc(Message& m)
      at System.Windows. Forms.Control.C ontrolNativeWin dow.OnMessage(M essage&
      m)
      at System.Windows. Forms.Control.C ontrolNativeWin dow.WndProc(Mes sage& m)
      at System.Windows. Forms.NativeWin dow.Callback(In tPtr hWnd, Int32 msg,
      IntPtr wparam, IntPtr lparam)
      >
      >
      Is somebody able to 'read' and translate this? I have a Label1 on top of
      (in
      front of) the Picturebox1. Is that the problem? Could this be caused by a
      repaint problem of the label?
      >
      Again: it does not happen in the IDE and not on Vista, only on the XP
      computers.
      >
      >
      According to the stack trace, the label is getting the paint message to
      paint itself (or repaint) and when it begins to update, it bombs off with no
      good error message. The "culprit" may or may not be the label, but the
      label's painting is throwing the exception....Wi thout attempting more
      debugging myself, I don't think I could give a reasonable guess at why it's
      throwing the exception. May want to google the exception....<s hrug>

      HTH,
      Mythran


      Comment

      • Arthur Ardolino

        #4
        Same Exact Problem

        I am experiencing the same exact problem. Label with a PictureBox underneath it with an animated gif. The only difference is that my exception says "System.Invalid OperationExcept ion: The object is currently in use elsewhere", but other than that, the stack trace is identical.

        If you find a solution to this problem, please let me know. Thanks.

        EggHeadCafe.com - .NET Developer Portal of Choice

        Comment

        • =?Utf-8?B?QWxpY2U=?=

          #5
          RE: Same Exact Problem

          @Mythran, thanks for your analysis. I did Google but found no solution.
          Because of the fact that it doesn't happen in the IDE it makes further
          debugging difficult. If I disable the label, it seems not to happen but I
          really need this label on top of the picturebox.

          @Arthur, same for you: please report in this thread anything you find on
          this subject. Do you also notice that it doesn't happen in Vista?

          Comment

          • Mythran

            #6
            Re: Same Exact Problem



            "Alice" <Alice@discussi ons.microsoft.c omwrote in message
            news:576AC5DA-B2DF-44BF-B656-4D5F5629857A@mi crosoft.com...
            @Mythran, thanks for your analysis. I did Google but found no solution.
            Because of the fact that it doesn't happen in the IDE it makes further
            debugging difficult. If I disable the label, it seems not to happen but I
            really need this label on top of the picturebox.
            >
            @Arthur, same for you: please report in this thread anything you find on
            this subject. Do you also notice that it doesn't happen in Vista?
            Alice,

            Can you post a short but complete code example that will repro this
            exception? I will check it out if I can get it.

            Thanks,
            Mythran


            Comment

            • =?Utf-8?B?QWxpY2U=?=

              #7
              RE: Same Exact Problem

              @Mythran, thanks for your analysis. I noticed the program does not crash when
              minimized all the time, that points to repaint indeed.

              @Arthur, hope you also report back here when you find something. Do you also
              have it only in XP and not in Vista?



              Comment

              • =?Utf-8?B?QWxpY2U=?=

                #8
                Re: Same Exact Problem

                Alice,
                >
                Can you post a short but complete code example that will repro this
                exception? I will check it out if I can get it.
                >
                I can try, but the error often does not occur until up to 20 hours or so. So
                I will need some time testing while 'undressing' the program. Unless I send
                you the complete zipped code of the current program but then I would need
                your e-mail address to send it to.

                Comment

                • Mythran

                  #9
                  Re: Same Exact Problem



                  "Alice" <Alice@discussi ons.microsoft.c omwrote in message
                  news:CE0C024C-E384-4315-9730-F86EEAA7375F@mi crosoft.com...
                  >Alice,
                  >>
                  >Can you post a short but complete code example that will repro this
                  >exception? I will check it out if I can get it.
                  >>
                  >
                  I can try, but the error often does not occur until up to 20 hours or so.
                  So
                  I will need some time testing while 'undressing' the program. Unless I
                  send
                  you the complete zipped code of the current program but then I would need
                  your e-mail address to send it to.
                  >
                  You can e-mail me the app if you want, or you can cut out any bloat the code
                  has and just send me a small portion of the app (the part that the crash
                  occurs)...up to you...

                  Mythran
                  kip_potter@(hot mail.com)



                  Comment

                  Working...