473,796 Members | 2,628 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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!


May 29 '07 #1
8 2671
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.
May 31 '07 #2


"Alice" <Al***@discussi ons.microsoft.c omwrote in message
news:02******** *************** ***********@mic rosoft.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
Jun 1 '07 #3
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
http://www.eggheadcafe.com
Jun 5 '07 #4
@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?
Jun 5 '07 #5


"Alice" <Al***@discussi ons.microsoft.c omwrote in message
news:57******** *************** ***********@mic rosoft.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
Jun 6 '07 #6
@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?

Jun 7 '07 #7
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.

Jun 7 '07 #8


"Alice" <Al***@discussi ons.microsoft.c omwrote in message
news:CE******** *************** ***********@mic rosoft.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)

Jun 8 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
48241
by: Michael Kennedy [UB] | last post by:
Hi Everyone, I have this multithreaded C# windows forms application which does a lot of image processing. Occasionally, I get the following error: A generic error occurred in GDI+. System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+. at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
5
2711
by: Pohihihi | last post by:
I am getting a generic GDI+ error on following code. Basically it is trying to capture screen image and save in a file. Is there a way to find more details on this error? Thanks for the help. --------------------------- ERROR MSG --------------------------- System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+. at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder,
2
22313
by: Alphonse Giambrone | last post by:
I am currently reading 'Programming The Web with Visual Basic .NET' and have so far found it to be excellent. Downloaded all the code from Apress and working in chapter 4, I get the error shown below. I am running IIS5 on WinXP Pro. Server Error in '/Chapter04' Application. ---------------------------------------------------------------------------- ---- A generic error occurred in GDI+. Description: An unhandled exception occurred...
3
6373
by: Ger | last post by:
I have a form with a panel (Panel1) in which I dynamically create picturebox controls. Works like a dream with static pictures, but not when the picturebox.image is an animated gif. GDI+ throws the following error in this case: "An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in system.windows.forms.dll Additional information: A generic error occurred in GDI+."
8
5041
by: Philip Wagenaar | last post by:
..43Hi, I am trying to extract tiff images from a multipage tiff and save them to disk. This is becoming almost a nightmare for me. I have seen several examples on the net that talk about this. For example : http://www.codeproject.com/vb/net/faxeditor.asp THis example should work great. But when I even try to load the multipage tiff that came with the example I receive a general gdi+ error. The same for a TIffManager Class written in...
15
5367
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the path of the uploaded image, and resize it with the provided dimensions. My function is below. The current function is returning an error when run from the upload function: A generic error occurred in GDI+. Not sure what exactly that means. From what...
0
3949
by: Robin van de Water [synthesiSFactory] | last post by:
Hi All, In one of my web applications, I intercepted the following error in the Application_Error part of the Global.Asax: GDI+ is not properly initialized (internal GDI+ error). The error as it was mentioned in the server's event viewer shows the following error message:
0
1247
by: James Wong | last post by:
Hi everybody, I'm facing a serious trouble relating to GDI+ generic error. The error message is "A Generic error occured in GDI+" and the following information is stored in Excepton object: System.Drawing.Graphics.CheckErrorStatus(Int32 status) System.Drawing.Graphics.DrawString(String s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format) System.Drawing.Graphics.DrawString(String s, Font font, Brush brush, PointF...
14
4111
by: James Wong | last post by:
Hi everybody, I'm facing a serious trouble relating to GDI+ generic error. The error message is "A Generic error occured in GDI+" and the following information is stored in Excepton object: System.Drawing.Graphics.CheckErrorStatus(Int32 status) System.Drawing.Graphics.DrawString(String s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format) System.Drawing.Graphics.DrawString(String s, Font font, Brush brush, PointF...
0
9680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10455
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10173
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10006
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6788
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.