473,806 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trouble of GDI+ generic error!

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.CheckE rrorStatus(Int3 2 status)
System.Drawing. Graphics.DrawSt ring(String s, Font font, Brush brush,
RectangleF layoutRectangle , StringFormat format)
System.Drawing. Graphics.DrawSt ring(String s, Font font, Brush brush,
PointF point, StringFormat format)

In my application, I use DrawString to print text on printer. This is a POS
application in retail store and one receipt is printed every minute in rush
hours. The symptom reported by user is the program stop response or no
receipt is printed after 3 or 4 hours operation during rush hours. The
above error message is logged by my appliction. After reboot the machine,
it works normally again for another few hours.

I suspect the problem is caused by memory corruption but no idea how to
trace to source. The suspects are:
1. my code
2. GDI+ / .NET Framework
3. hardware (e.g. insufficient RAM)

I've also tried to add some GC.Collect() code in my code but there's no
improvement at all.

Here is the hardware / software configuration to run my application:
1. Intel Celeron 2G with 512MB
2. Star TSP 700 printer
3. Windows XP Professional with SP2 and latest patches
4. .NET Framework 2.0
5. SQL Server 2000 Desktop Edition with latest patches
6. Application compiled by VB.NET 2005

Would anybody have any idea how I can trace the source of this problem?
Thanks a lot for your attention and kindly advice!

Regards,
James Wong
Mar 20 '07
14 4115
Hi Steven,

I still have something not quite sure about when I should call Dispose. The
followings are some pseudo code to show my question:
Public Shared Sub A()

Dim objFont As Font

objFont = New Font (...)

Call B (objFont)

' I should call objFont.Dispose here before end of the sub, right?

Call B (New Font (...))

' if I call sub B in this way (without creating a variable), how can I
call Dispose?

End Sub
Public Shared Sub B(ByVal objFont As Font)

'... do something here with objFont

' Do I need to call objFont.Dispose here before end of the sub?

' I'm not quite sure that objFont in this sub is an independent instance
from objFont in Sub A

End Sub
And you may right that I use a lot of font objects to print and this may be
the major cause of my problem.

Thanks again for your help!

Regards,
James Wong
"Steven Cheng[MSFT]" <st*****@online .microsoft.com¼ ¶¼g©ó¶l¥ó·s»D:N c************** **@TK2MSFTNGHUB 02.phx.gbl...
Hi James,

For those graphics objects such as Brush, Bitmap, Font... they will hold
win32 unmanaged resource handle, thus, whenever you have used large number
of such objects and haven't explcitly dispose them at ealiear time,
they'll
hold significant operating system resource(GDI handles). Therefore, you're
recommended to explicitly dispose them after finishing use them.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.

Mar 26 '07 #11
Thanks for your reply james,

Regardingon the those managed GDI+ objects(such as Pen, Brush, Font ....),
you're recommended to dispose it rigth after you've finished using it (in a
certain GDI+ function call such as DrawXXX). Generally, you can consider
put the object disposing code at the end of the certain function which
perform a GDI+ task.

In addition, here is a GDI+ FAQ article about when to dispose object:

#Disposing of GDI+ resources
http://www.bobpowell.net/disposing_of_resources.htm

and there are many other useful faq articles on GDI+ there:

http://www.bobpowell.net/faqmain.htm

Hope this also helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 28 '07 #12
Hi Steven,

Thanks for your information! I've modified my code and the situation seems
to be better than before. I'm still monitoring the performance and behavior
of my new style coding. I'll let you know if this solve my problem
eventually.

Regards,
James Wong

"Steven Cheng[MSFT]" <st*****@online .microsoft.com¼ ¶¼g©ó¶l¥ó·s»D:9 s************** @TK2MSFTNGHUB02 .phx.gbl...
Thanks for your reply james,

Regardingon the those managed GDI+ objects(such as Pen, Brush, Font ....),
you're recommended to dispose it rigth after you've finished using it (in
a
certain GDI+ function call such as DrawXXX). Generally, you can consider
put the object disposing code at the end of the certain function which
perform a GDI+ task.

In addition, here is a GDI+ FAQ article about when to dispose object:

#Disposing of GDI+ resources
http://www.bobpowell.net/disposing_of_resources.htm

and there are many other useful faq articles on GDI+ there:

http://www.bobpowell.net/faqmain.htm

Hope this also helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.

Mar 29 '07 #13
Hi James,

Glad that you've got progress on this.

Sure, if there is anything else we can help, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 30 '07 #14
Hi James,

Have you resolved the issue or still anything need our help?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 3 '07 #15

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

Similar topics

4
48242
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)
3
3628
by: cdj | last post by:
Hi all, I've got a picturebox on a form, and a save button. When I go to save, the app craps out with the following error: ================== An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in system.drawing.dll
5
2713
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
22315
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...
13
4667
by: lgbjr | last post by:
Hello All, I have some pictureboxes on a VB.NET form that are linked to an AccessDB. If the user wishes to open or edit an image, I need to save the image in the picturebox to a temp file, then open that file in whatever viewer/editor is the default for the users system. I tried to do picturebox1.image.save(filename), which results in "A Generic error occured in GDI+". However, if I use an unbound picturebox, do a
15
5372
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
1251
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
1401
by: manini | last post by:
Hello Everyone I m getting the generic GDI + error,Please help me to resolve this error ************** Exception Text ************** System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+. at System.Drawing.Graphics.CheckErrorStatus(Int32 status) at System.Drawing.Graphics.DrawString(String s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format) at...
0
9597
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10620
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...
0
10369
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10372
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
9187
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...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5682
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3851
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
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.