473,797 Members | 3,212 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 #1
14 4111
Hi James,

From your description, you're encountering the following error:

"A Generic error occured in GDI+......."

in a winform application which print outo some string data into printer,
correct?

As for the "A Generic error occured in GDI+", it does be a very generic
exception that will sometimes occur in graphics application. I'm not sure
whether your applciation's code logic is very complex and contains many
other codelogic (not related to the GDI+ printing)? if so, I would suggest
you try creating a simplified project that dedicate the GDI+ processing to
see whether you can reproduce the issue.

For memory specific issue, a commom diagnostic means is using the
performance counter(process memory) to montior the managed and unmanaged
memory usage of your application's running process. You can check whether
there is particular memory pressure(at unmanaged or managed memory ...).

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

=============== =============== =============== =====

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 20 '07 #2
Hi Steven,

Thanks for your response!

Yes, I got this error while printing something to printer in WinForm
application. However, this problem does not occurs everytime when I print,
so it's not easy to reproduce. What I can ensure is that if the program
runs for 3 or 4 hours (maybe around 200+ receipts are printed), this problem
may happen. After restarting the program (no need to reboot), it resumes to
normal for another few hours before the problem occurs again.

For the performance count, I found it may be useful for me to monitor the
memory status. However, there are so many counter names under memory and
process categories, will you suggest me to focus some of them in my
application?

Thanks again for your advice!

Regards,
James Wong

"Steven Cheng[MSFT]" <st*****@online .microsoft.com¼ ¶¼g©ó¶l¥ó·s»D:6 v************** @TK2MSFTNGHUB02 .phx.gbl...
Hi James,

From your description, you're encountering the following error:

"A Generic error occured in GDI+......."

in a winform application which print outo some string data into printer,
correct?

As for the "A Generic error occured in GDI+", it does be a very generic
exception that will sometimes occur in graphics application. I'm not sure
whether your applciation's code logic is very complex and contains many
other codelogic (not related to the GDI+ printing)? if so, I would suggest
you try creating a simplified project that dedicate the GDI+ processing to
see whether you can reproduce the issue.

For memory specific issue, a commom diagnostic means is using the
performance counter(process memory) to montior the managed and unmanaged
memory usage of your application's running process. You can check whether
there is particular memory pressure(at unmanaged or managed memory ...).

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

=============== =============== =============== =====

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no
rights.

Mar 20 '07 #3
Thanks for your reply James,

For memory specific performance counters, the following twos are very
useful:

category counter name

Process Private Bytes
NET CLR Memory #Bytes in all Heaps

"Private Bytes" counter(of Process category) is used to inspect the
physical private bytes consumed by your application process

"#Bytes in all Heaps" counter(of .NET CLR Memory category) is used to check
all the bytes in .NET managed heap

Here is a good msdn reference introducing production debugging of .NET
application

#Production Debugging for .NET Framework Applications
http://msdn2.microsoft.com/en-us/library/ms954591.aspx

And normally, memory issue in .net framework application will possibly be
caused by following things:

Caching/Session state
Large amount of sites
Debug mode
XSLT Transformations/XML Serialization
Pinning
Binary Formatter
Large Object Heap
COM objects with Events
Blocked Finalizer

Hope this also helps some.

Sincerely,

Steven Cheng

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

Mar 21 '07 #4
Hi Steven,

Thanks again for your reply!

I'll try to figure out what's happen on my application.

Regards,
James Wong

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

For memory specific performance counters, the following twos are very
useful:

category counter name

Process Private Bytes
NET CLR Memory #Bytes in all Heaps

"Private Bytes" counter(of Process category) is used to inspect the
physical private bytes consumed by your application process

"#Bytes in all Heaps" counter(of .NET CLR Memory category) is used to
check
all the bytes in .NET managed heap

Here is a good msdn reference introducing production debugging of .NET
application

#Production Debugging for .NET Framework Applications
http://msdn2.microsoft.com/en-us/library/ms954591.aspx

And normally, memory issue in .net framework application will possibly be
caused by following things:

Caching/Session state
Large amount of sites
Debug mode
XSLT Transformations/XML Serialization
Pinning
Binary Formatter
Large Object Heap
COM objects with Events
Blocked Finalizer

Hope this also helps some.

Sincerely,

Steven Cheng

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



Mar 21 '07 #5
Just a wild guess, but are you sure you dispose of the brush and font used to
draw the string after each call to your routine.
--
Dennis in Houston
"James Wong" wrote:
Hi Steven,

Thanks again for your reply!

I'll try to figure out what's happen on my application.

Regards,
James Wong

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

For memory specific performance counters, the following twos are very
useful:

category counter name

Process Private Bytes
NET CLR Memory #Bytes in all Heaps

"Private Bytes" counter(of Process category) is used to inspect the
physical private bytes consumed by your application process

"#Bytes in all Heaps" counter(of .NET CLR Memory category) is used to
check
all the bytes in .NET managed heap

Here is a good msdn reference introducing production debugging of .NET
application

#Production Debugging for .NET Framework Applications
http://msdn2.microsoft.com/en-us/library/ms954591.aspx

And normally, memory issue in .net framework application will possibly be
caused by following things:

Caching/Session state
Large amount of sites
Debug mode
XSLT Transformations/XML Serialization
Pinning
Binary Formatter
Large Object Heap
COM objects with Events
Blocked Finalizer

Hope this also helps some.

Sincerely,

Steven Cheng

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



Mar 22 '07 #6
Hi James,

If you get any progress or if there is anything else we can help you,
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 22 '07 #7
Hi Dennis,

Thanks for your hints. I don't dispose brush or font after drawing. Do you
mean I have to do so and it may be the cirtical point to my problem?
Anyway, I'll try to dispose them and see the result.

Regards,
James Wong

"Dennis" <De****@discuss ions.microsoft. com¼¶¼g©ó¶l¥ó·s »D:B5********** *************** *********@micro soft.com...
Just a wild guess, but are you sure you dispose of the brush and font used
to
draw the string after each call to your routine.
--
Dennis in Houston

Mar 23 '07 #8
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 23 '07 #9
Hi Steven,

Thanks for your information!

By the way, I've got another problem related to .NET framework and I've
posted it with subject ".NET runtime error" in newsgroup .dotnet.framewo rk.
However, there is no response there for over two days. Would you have a
look and give me some hints? Thanks a lot!

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 #10

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)
3
3627
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
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
22314
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
4665
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
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
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...
0
1400
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
9685
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
9537
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
10469
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
10246
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
10209
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
9066
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
4135
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3750
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2934
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.