473,320 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Generic Error in GDI+

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 during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.ExternalException: A
generic error occurred in GDI+.

Source Error:
Line 76: .DrawString(Text, fnt, New SolidBrush(Color.White), 0, 0)
Line 77:
Line 78: bmp.Save(Path, System.Drawing.Imaging.ImageFormat.Gif)
Line 79: m_iHeight = bmp.Height
Line 80: m_iWidth = bmp.Width
Source File: D:\Inetpub\wwwroot\Chapter04\ImageCreation.aspx.vb Line: 78

Stack Trace:
[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Image.Save(String filename, ImageCodecInfo encoder,
EncoderParameters encoderParams) +582
System.Drawing.Image.Save(String filename, ImageFormat format) +61
Chapter_04.ImageCreation.CreateImage(String Text, String& Path) in
D:\Inetpub\wwwroot\Chapter04\ImageCreation.aspx.vb :78
Chapter_04.ImageCreation.inimgGo_ServerClick(Objec t sender,
ImageClickEventArgs e) in
D:\Inetpub\wwwroot\Chapter04\ImageCreation.aspx.vb :40

System.Web.UI.HtmlControls.HtmlInputImage.OnServer Click(ImageClickEventArgs
e) +109

System.Web.UI.HtmlControls.HtmlInputImage.System.W eb.UI.IPostBackEventHandle
r.RaisePostBackEvent(String eventArgument) +67
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277

----------------------------------------------------------------------------
----

Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
Version:1.1.4322.573

--

Here is the full code for the routine:
Private Sub CreateImage(ByVal Text As String, _

ByRef Path As String)

Dim fnt As New Font("Verdana", 40)

Dim dummy As Bitmap = New Bitmap(1, 1)

Dim gfx As Graphics = Graphics.FromImage(dummy)

Dim size As SizeF = gfx.MeasureString(Text, fnt)

gfx.Dispose()

dummy = Nothing

Dim bmp As Bitmap = New Bitmap(CInt(size.Width), CInt(size.Height))

gfx = Graphics.FromImage(bmp)

With gfx

..CompositingQuality = Drawing.Drawing2D.CompositingQuality.HighQuality

..InterpolationMode = Drawing.Drawing2D.InterpolationMode.HighQualityBic ubic

..SmoothingMode = Drawing.Drawing2D.SmoothingMode.HighQuality

..TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias

..FillRectangle( _

New Drawing2D.LinearGradientBrush( _

New Point(0, CInt(size.Height) - 1), _

New Point(CInt(size.Width) - 1, 0), _

Color.Red, _

Color.Black), _

0, 0, CInt(size.Width), CInt(size.Height))

..DrawString(Text, fnt, New SolidBrush(Color.White), 0, 0)

bmp.Save(Path, System.Drawing.Imaging.ImageFormat.Gif)

m_iHeight = bmp.Height

m_iWidth = bmp.Width

..Dispose()

End With

End Sub

Can anyone point me to a cause/fix??

Any help would be appreciated.
Alphonse Giambrone
Email: NO****@customdatasolutions.us
For email replace NOSPAM with agiam

Nov 17 '05 #1
2 22270
Instead of using the Overloaded method
System.Drawing.Image.Save(String, System.Drawing.Imaging.ImageFormat.Jpeg);

depending on what you want to do use one of the following:

System.Drawing.Image.Save(System.IO.FileStream,
System.Drawing.Imaging.ImageFormat.Jpeg);

or

System.Drawing.Image.Save(System.IO.MemoryStream,
System.Drawing.Imaging.ImageFormat.Jpeg);

Apparently from ASP.Net you will get this error when you are using a file
path as a string. If this does not solve your problem then look at security
issues. The ASPNET useraccount may not have permissions to write to disk.

"Alphonse Giambrone" <NO*********@customdatasolutions.us> wrote in message
news:uk**************@TK2MSFTNGP10.phx.gbl...
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 during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.ExternalException: A
generic error occurred in GDI+.

Source Error:
Line 76: .DrawString(Text, fnt, New SolidBrush(Color.White), 0, 0) Line 77:
Line 78: bmp.Save(Path, System.Drawing.Imaging.ImageFormat.Gif)
Line 79: m_iHeight = bmp.Height
Line 80: m_iWidth = bmp.Width
Source File: D:\Inetpub\wwwroot\Chapter04\ImageCreation.aspx.vb Line: 78
Stack Trace:
[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Image.Save(String filename, ImageCodecInfo encoder,
EncoderParameters encoderParams) +582
System.Drawing.Image.Save(String filename, ImageFormat format) +61
Chapter_04.ImageCreation.CreateImage(String Text, String& Path) in
D:\Inetpub\wwwroot\Chapter04\ImageCreation.aspx.vb :78
Chapter_04.ImageCreation.inimgGo_ServerClick(Objec t sender,
ImageClickEventArgs e) in
D:\Inetpub\wwwroot\Chapter04\ImageCreation.aspx.vb :40

System.Web.UI.HtmlControls.HtmlInputImage.OnServer Click(ImageClickEventArgs e) +109

System.Web.UI.HtmlControls.HtmlInputImage.System.W eb.UI.IPostBackEventHandle r.RaisePostBackEvent(String eventArgument) +67
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277

-------------------------------------------------------------------------- -- ----

Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573

--

Here is the full code for the routine:
Private Sub CreateImage(ByVal Text As String, _

ByRef Path As String)

Dim fnt As New Font("Verdana", 40)

Dim dummy As Bitmap = New Bitmap(1, 1)

Dim gfx As Graphics = Graphics.FromImage(dummy)

Dim size As SizeF = gfx.MeasureString(Text, fnt)

gfx.Dispose()

dummy = Nothing

Dim bmp As Bitmap = New Bitmap(CInt(size.Width), CInt(size.Height))

gfx = Graphics.FromImage(bmp)

With gfx

.CompositingQuality = Drawing.Drawing2D.CompositingQuality.HighQuality

.InterpolationMode = Drawing.Drawing2D.InterpolationMode.HighQualityBic ubic
.SmoothingMode = Drawing.Drawing2D.SmoothingMode.HighQuality

.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias

.FillRectangle( _

New Drawing2D.LinearGradientBrush( _

New Point(0, CInt(size.Height) - 1), _

New Point(CInt(size.Width) - 1, 0), _

Color.Red, _

Color.Black), _

0, 0, CInt(size.Width), CInt(size.Height))

.DrawString(Text, fnt, New SolidBrush(Color.White), 0, 0)

bmp.Save(Path, System.Drawing.Imaging.ImageFormat.Gif)

m_iHeight = bmp.Height

m_iWidth = bmp.Width

.Dispose()

End With

End Sub

Can anyone point me to a cause/fix??

Any help would be appreciated.
Alphonse Giambrone
Email: NO****@customdatasolutions.us
For email replace NOSPAM with agiam

Nov 17 '05 #2
Mark,

Thanks for the quick response. I do need to save it as a file. At this stage
I am just trying to follow the book. My first thought was a permission
problem also and I went into IIS and enabled write permission for the
folder. The default user account was IUSR. I tried IWAM and ASPNET
(restarting IIS each time), still the same problem.
Any more ideas?

--

Alphonse Giambrone
Email: NO****@customdatasolutions.us
For email replace NOSPAM with agiam
"Mark Miller" <no**********@waveshift.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Instead of using the Overloaded method
System.Drawing.Image.Save(String, System.Drawing.Imaging.ImageFormat.Jpeg);
depending on what you want to do use one of the following:

System.Drawing.Image.Save(System.IO.FileStream,
System.Drawing.Imaging.ImageFormat.Jpeg);

or

System.Drawing.Image.Save(System.IO.MemoryStream,
System.Drawing.Imaging.ImageFormat.Jpeg);

Apparently from ASP.Net you will get this error when you are using a file
path as a string. If this does not solve your problem then look at security issues. The ASPNET useraccount may not have permissions to write to disk.

"Alphonse Giambrone" <NO*********@customdatasolutions.us> wrote in message
news:uk**************@TK2MSFTNGP10.phx.gbl...
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 during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.ExternalException: A
generic error occurred in GDI+.

Source Error:
Line 76: .DrawString(Text, fnt, New SolidBrush(Color.White), 0,

0)
Line 77:
Line 78: bmp.Save(Path, System.Drawing.Imaging.ImageFormat.Gif)
Line 79: m_iHeight = bmp.Height
Line 80: m_iWidth = bmp.Width
Source File: D:\Inetpub\wwwroot\Chapter04\ImageCreation.aspx.vb Line:

78

Stack Trace:
[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Image.Save(String filename, ImageCodecInfo encoder,
EncoderParameters encoderParams) +582
System.Drawing.Image.Save(String filename, ImageFormat format) +61
Chapter_04.ImageCreation.CreateImage(String Text, String& Path) in
D:\Inetpub\wwwroot\Chapter04\ImageCreation.aspx.vb :78
Chapter_04.ImageCreation.inimgGo_ServerClick(Objec t sender,
ImageClickEventArgs e) in
D:\Inetpub\wwwroot\Chapter04\ImageCreation.aspx.vb :40

System.Web.UI.HtmlControls.HtmlInputImage.OnServer Click(ImageClickEventArgs
e) +109

System.Web.UI.HtmlControls.HtmlInputImage.System.W eb.UI.IPostBackEventHandle
r.RaisePostBackEvent(String eventArgument) +67
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33 System.Web.UI.Page.ProcessRequestMain() +1277



--------------------------------------------------------------------------
--
----

Version Information: Microsoft .NET Framework Version:1.1.4322.573;

ASP.NET
Version:1.1.4322.573

--

Here is the full code for the routine:
Private Sub CreateImage(ByVal Text As String, _

ByRef Path As String)

Dim fnt As New Font("Verdana", 40)

Dim dummy As Bitmap = New Bitmap(1, 1)

Dim gfx As Graphics = Graphics.FromImage(dummy)

Dim size As SizeF = gfx.MeasureString(Text, fnt)

gfx.Dispose()

dummy = Nothing

Dim bmp As Bitmap = New Bitmap(CInt(size.Width), CInt(size.Height))

gfx = Graphics.FromImage(bmp)

With gfx

.CompositingQuality = Drawing.Drawing2D.CompositingQuality.HighQuality

.InterpolationMode =

Drawing.Drawing2D.InterpolationMode.HighQualityBic ubic

.SmoothingMode = Drawing.Drawing2D.SmoothingMode.HighQuality

.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias

.FillRectangle( _

New Drawing2D.LinearGradientBrush( _

New Point(0, CInt(size.Height) - 1), _

New Point(CInt(size.Width) - 1, 0), _

Color.Red, _

Color.Black), _

0, 0, CInt(size.Width), CInt(size.Height))

.DrawString(Text, fnt, New SolidBrush(Color.White), 0, 0)

bmp.Save(Path, System.Drawing.Imaging.ImageFormat.Gif)

m_iHeight = bmp.Height

m_iWidth = bmp.Width

.Dispose()

End With

End Sub

Can anyone point me to a cause/fix??

Any help would be appreciated.
Alphonse Giambrone
Email: NO****@customdatasolutions.us
For email replace NOSPAM with agiam


Nov 17 '05 #3

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

Similar topics

4
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+....
3
by: T. Davis | last post by:
In C#, I am able to successfully stream a TIFF image that comes from a BLOB field in a database, save it to file, then convert the pages within TIFF file into jpegs (using GDI+) and display on the...
13
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...
15
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...
0
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:...
14
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:...
0
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...
7
by: j4richard | last post by:
Help please, I am getting this "Unhandled Exception has occurred in your application" " A Generic error occurred in GDI+" See the end of this message for details on...
1
by: Jeff | last post by:
hi asp.net 2.0 I'm experimenting with GDI+ in asp.net and get an "A generic error occurred in GDI+." exception. Below is my code, I've marked a line with "<<<<-- here". It's here the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.