Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8381001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:36:06+00:00 2026-06-09T16:36:06+00:00

i am getting error A generic error occurred in GDI+ on line bit.Save(str, Imaging.ImageFormat.Png)

  • 0

i am getting error A generic error occurred in GDI+
on line

bit.Save(str, Imaging.ImageFormat.Png)

please help me on this here is my full code

   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If IsNothing(Request.QueryString("id")) = False Then
                If Val(Request.QueryString("id")) > 0 Then
                    Dim dsFiles As New DataSet

                    dsFiles = oFileData.GetFile(Val(Request.QueryString("id")))
                    Dim bindata() As Byte = dsFiles.Tables(0).Rows(0).Item("FileData")
                    Dim str As New MemoryStream
                    str.Write(bindata, 0, dsFiles.Tables(0).Rows(0).Item("FileSize"))
                    Dim bit As Bitmap = New Bitmap(str)
                    Response.ContentType = ".png"
                    bit.Save(str, Imaging.ImageFormat.Png)
                    str.WriteTo(Response.OutputStream)
                    str.Close()
                Else
                    Response.Write("<script language=""javascript"" type=""text/javascript"">window.close();</script>")
                End If
            Else
                Response.Write("<script language=""javascript"" type=""text/javascript"">window.close();</script>")
            End If
        End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T16:36:07+00:00Added an answer on June 9, 2026 at 4:36 pm

    There may be many reasons – may be the content of byte array is not valid image data. In fact no need to create Bitmap or MemoryStream to write image data/bytes to response stream.

    Try this,

    Dim bindata() As Byte = dsFiles.Tables(0).Rows(0).Item("FileData")
    Response.ContentType = "image/png"
    Response.BinaryWrite(bindata)
    Response.Flush()
    Response.End()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting the error Generic error occurred in GDI+ in my sample code
Why I'm getting A Generic Error occurred in GDI+ Exception ? IntPtr hicon =
I am getting this error: An unhandled exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll
I'm trying to use this but getting a generic error at the lines following
I'm trying to resave an image and am getting the error A generic error
Getting error when I tried like this: $ci =& get_instance(); $ci->db->select(CONCAT_WS(' ',users.name_first,users.name_last) AS user_name,CONCAT_WS('
I dont know what could be missing here but I keep getting this error
I have this header file ... for some reason I keep getting an error
I'm getting this error and I can't make head or tail of it. The
I'm getting error: Connection must be valid and open when I start this program.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.