Generic Error in GDI+

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default 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: [email]NOSPAM@customdatasolutions.us[/email]
    For email replace NOSPAM with agiam



    Alphonse Giambrone Guest

  2. Similar Questions and Discussions

    1. Generic Server Error??
      Is there a way to customize generic server errors like the one you might get if coldfusion happens to be restarting? For example, I can produce an...
    2. Generic CMS
      I am constantly writing and re-writng Content Management Systems for every website I develop, and re-writing forms which input data into a database...
    3. Generic Web app SSL
      Company A has a web app product. They sell it to 10 other companies and wish several of the pages to be secure. Once the product is placed on...
    4. generic do
      hi Does anybody know how to get the gerneric do dialog box up, so I can edit a string of code i inserted, also how do i make generic do go to a...
    5. generic win32 host error
      Generic Win32 host process has encountered an error and needs to close. We're sorry for the inconvenience. Note: KB shows this type of error...
  3. #2

    Default Re: Generic Error in GDI+

    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" <NOSPAMagiam@customdatasolutions.us> wrote in message
    news:ukeMW8iVDHA.2052@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: [email]NOSPAM@customdatasolutions.us[/email]
    > For email replace NOSPAM with agiam
    >
    >
    >

    Mark Miller Guest

  4. #3

    Default Re: Generic Error in GDI+

    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: [email]NOSPAM@customdatasolutions.us[/email]
    For email replace NOSPAM with agiam


    "Mark Miller" <no_mark_spam@waveshift.com> wrote in message
    news:%23Qz6zLjVDHA.1280@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" <NOSPAMagiam@customdatasolutions.us> wrote in message
    > news:ukeMW8iVDHA.2052@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: [email]NOSPAM@customdatasolutions.us[/email]
    > > For email replace NOSPAM with agiam
    > >
    > >
    > >
    >
    >

    Alphonse Giambrone Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139