Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net GDI+;中发生一般性错误;_Asp.net_Vb.net_Image - Fatal编程技术网

Asp.net GDI+;中发生一般性错误;

Asp.net GDI+;中发生一般性错误;,asp.net,vb.net,image,Asp.net,Vb.net,Image,我收到错误GDI+中发生一般错误 在线 请帮我这是我的全部代码 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

我收到错误GDI+中发生一般错误
在线

请帮我这是我的全部代码

   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
Protected Sub Page_Load(ByVal sender作为对象,ByVal e作为System.EventArgs)处理Me.Load
如果IsNothing(Request.QueryString(“id”))=False,那么
如果Val(Request.QueryString(“id”))大于0,则
将DSF文件设置为新数据集
dsFiles=oFileData.GetFile(Val(Request.QueryString(“id”))
Dim bindata()的字节=dsFiles.Tables(0).Rows(0).Item(“FileData”)
Dim str作为新的内存流
str.Write(bindata,0,dsFiles.Tables(0).行(0).项(“文件大小”))
作为位图的Dim位=新位图(str)
Response.ContentType=“.png”
保存(str,Imaging.ImageFormat.Png)
str.WriteTo(Response.OutputStream)
str.Close()
其他的
Response.Write(“window.close();”)
如果结束
其他的
Response.Write(“window.close();”)
如果结束
端接头

可能有很多原因-可能是字节数组的内容不是有效的图像数据。实际上,无需创建
位图
内存流
,即可将图像数据/字节写入响应流

试试这个

Dim bindata() As Byte = dsFiles.Tables(0).Rows(0).Item("FileData")
Response.ContentType = "image/png"
Response.BinaryWrite(bindata)
Response.Flush()
Response.End()
Dim bindata() As Byte = dsFiles.Tables(0).Rows(0).Item("FileData")
Response.ContentType = "image/png"
Response.BinaryWrite(bindata)
Response.Flush()
Response.End()