“/tpxx”应用程序中的服务器错误。 
________________________________________
GDI+ 中发生一般性错误。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Runtime.InteropServices.ExternalException: GDI+ 中发生一般性错误。源错误: 
执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。 堆栈跟踪: [ExternalException (0x80004005): GDI+ 中发生一般性错误。]
   System.Drawing.Image.FromFile(String filename, Boolean useEmbeddedColorManagement) +380120
   AlbumOnNet.Internal.a.a(String A_0, Int32 A_1, Int32 A_2, Int32 A_3, Boolean A_4, Int32& A_5, Int32& A_6, Int32& A_7, Int32& A_8, d& A_9) +44[Exception: Error reading image file. Note that encrypted files are not supported.]
   AlbumOnNet.Internal.a.a(String A_0, Int32 A_1, Int32 A_2, Int32 A_3, Boolean A_4, Int32& A_5, Int32& A_6, Int32& A_7, Int32& A_8, d& A_9) +125
   AlbumOnNet.AlbumBuilder.a(AlbumBuildType A_0) +676
   AlbumOnNet.AlbumBuilder.Load() +78
   AlbumOnNet.Album.a() +218
   AlbumOnNet.Album.RefreshAlbum() +140
   AlbumOnNet.Album.OnLoad(EventArgs e) +13
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061________________________________________
版本信息: Microsoft .NET Framework 版本:2.0.50727.42; ASP.NET 版本:2.0.50727.42

解决方案 »

  1.   

    保存/生成图片的文件夹已经分了读写修改权限,everyone,asp.net,administrator 用户都加了完全控制权限,还是老样,甚至将保存图片的文件夹中的所有的bmp都转jpg了,并将代码改写为职能上传jpg 和 gif图片,这问题依然存在。
      

  2.   

    加一个Network Service的读写权限看看
      

  3.   

    如果使用了MemeroyStream,是否有关闭?如果有关闭也会造成这个问题.建议还是贴部分代码出来.
      

  4.   

    <%@ Page Language="C#" Debug="true" %>
    <%@ import Namespace="System" %>
    <%@ import Namespace="System.Data" %>
    <%@ import Namespace="System.Data.OleDb" %>
    <%@ import Namespace="System.Collections" %>
    <%@ import Namespace="System.ComponentModel" %>
    <%@ import Namespace="System.Drawing" %>
    <%@ import Namespace="System.Web" %>
    <%@ import Namespace="System.Web.SessionState" %>
    <%@ import Namespace="System.Web.UI" %>
    <%@ import Namespace="System.Web.UI.WebControls" %>
    <%@ import Namespace="System.Web.UI.HtmlControls" %>
    <%@ import Namespace="System.IO" %>
    <script runat="server">
         protected System.Int32 FileLength = 0;
         //-----------------------------------------------------------------------------
         public void Page_Load()
         {
               string strConnect = "Provider=msdaora;Data Source=zymis;User Id=tpxx;Password=tpxx2005;";           OleDbConnection objConnection = new OleDbConnection(strConnect);
               objConnection.Open();           OleDbCommand objCommand = new OleDbCommand();
               objCommand.Connection = objConnection;
               objCommand.CommandType = CommandType.Text;           OleDbDataAdapter da = new OleDbDataAdapter();
               da.SelectCommand = objCommand;
               DataSet ds = new DataSet();           string selectSql = "Select ClassName From pic_class";
               objCommand.CommandText = selectSql;
               da.Fill(ds, "pic_class");           DropDownList1.DataTextField="ClassName";
               DropDownList1.DataValueField="ClassName";
               DropDownList1.DataSource=ds.Tables["pic_class"].DefaultView;
               objConnection.Close();
               if(!IsPostBack){
                  DropDownList1.DataBind();
               }
         }
         //-----------------------------------------------------------------------------
         void Button1_Click(object sender, EventArgs e) {
            HttpPostedFile UpFile=UpPhoto.PostedFile;
            FileLength = UpFile.ContentLength;
            string filetype=UpPhoto.PostedFile.ContentType;
            try
            {
               if (FileLength == 0){
                   Response.Write("<script language=javascript>alert('还没有选择上传的图片,请选择!');</"+"script>");
               }
               else{
                   if(filetype!="image/gif" && filetype!="image/pjpeg"){// filetype!="image/bmp" && filetype!="image/tiff" && filetype!="image/x-icon" && filetype!="image/x-png" && filetype!="image/x-emf" && filetype!="image/x-exif" && filetype!="image/x-wmf"
                      Response.Write("<script language=javascript>alert('无效的图形格式,请选择图形文件(请先将图片转换为jpg或gif格式后再上传)!');</"+"script>");
                   }
                   else{
                      string path = Server.MapPath("/tpxx/albums/"+UpPhoto.PostedFile.FileName.Substring(UpPhoto.PostedFile.FileName.LastIndexOf('\\')+1));
                      if(File.Exists(path)){
                         Response.Write("<script language=javascript>alert('已经有同名文件,请更改文件名或另选一张!');</"+"script>");
                      }
                      else{
                         string xmlfile = Server.MapPath("/tpxx/albums/AlbumOnNet.xml");//文件的路径和文件名
                         if(File.Exists(xmlfile)){//检查该文件是否存在,若存在
                            File.Delete(xmlfile);//将该文件删除
                         }                     Stream fs= UpFile.InputStream;
                         int upPhotoLength=UpFile.ContentLength;
                         Byte[] mydata=new byte[fs.Length];
                         fs.Read(mydata,0, upPhotoLength);                     String Connectstr = "Provider=msdaora;Data Source=zymis;User Id=tpxx;Password=tpxx2005;";
                         OleDbConnection Connection = new OleDbConnection(Connectstr);                     string picdate=TextBox1.Text;
                         string unit=TextBox2.Text;
                         string picname=UpPhoto.PostedFile.FileName.Substring(UpPhoto.PostedFile.FileName.LastIndexOf('\\')+1);
                         string yielder=TextBox4.Text;
                         string yielddate=TextBox5.Text;
                         string other=TextBox6.Text;
                         string clas=DropDownList1.SelectedItem.Text;                     OleDbCommand Command = new OleDbCommand("INSERT INTO pic_info(PicDate, Unit, Class, PicName, yielder, yieldDate, other) VALUES (to_date('"+picdate+"','yyyy-mm-dd'),'"+unit+"','"+clas+"','"+picname+"','"+yielder+"',to_date('"+yielddate+"','yyyy-mm-dd'),'"+other+"')",Connection);                     //string newfile="albums/"+UpPhoto.PostedFile.FileName.Substring(UpPhoto.PostedFile.FileName.LastIndexOf('\\')+1)+".jpg";
                         //output.Save(Server.MapPath(newfile),System.Drawing.Imaging.ImageFormat.Jpeg);// 将图片经过格式转换后存储
                         //ImgPreview.ImageUrl=newfile;
                         UpPhoto.PostedFile.SaveAs(Server.MapPath("/tpxx/albums/"+UpPhoto.PostedFile.FileName.Substring(UpPhoto.PostedFile.FileName.LastIndexOf('\\')+1)));//将图片上传到albums目录下
                         Connection.Open();
                         Command.ExecuteNonQuery();
                         Connection.Close();
                         Response.Write("<script language=javascript>alert('图片上传成功!');</"+"script>");                     Page.RegisterStartupScript("do_url","<script lanuage=javascript>document.all.TextBox1.focus();</"+"script>");
                      }
                   }
                }
             }
             catch (System.Exception ex)
             {
                Response.Write(ex.Message.ToString());
             }
         }
    </script>
      

  5.   

    没看到代码里有
    System.Drawing.Image.FromFile(String filename
    不全吧
      

  6.   

    下面的这句完成上传图片
    UpPhoto.PostedFile.SaveAs(Server.MapPath("/tpxx/albums/"+UpPhoto.PostedFile.FileName.Substring(UpPhoto.PostedFile.FileName.LastIndexOf('\\')+1)));//将图片上传到albums目录下
      

  7.   

    把你这句 输出看看字符串是多少:Server.MapPath("/tpxx/albums/"+UpPhoto.PostedFile.FileName.Substring(UpPhoto.PostedFile.FileName.LastIndexOf('\\')+1))怀疑是因为你的路径不正确。,没有后缀名。
      

  8.   

    A:GDI+ 中发生一般性错误B:关于您提到的“System.Runtime.InteropServices.ExternalException: GDI+ 中发生一般性错误,”的问题,根据我的经验,是由于代码中img.Save(FilePath,ImageFormat.Bmp);引起的。
    原因是因为Html网页及Http协议不支持BMP格式的图片文件导致的。而解决方法就是我们在调用Save方法时将格式转化为JPEG或者GIF,但由于GIF仅支持256色,会引起图片失真,所以我建议转化为JPEG格式,如下语句:
    img.Save(FilePath, ImageFormat.Jpeg);A:如果这个文件夹中有这个名字的图片就包错误
    这是怎么回事?
    可以创建图片文件了,
    我也不知道是那个问题B:请问您做过图片的转化了吗?是转化为JPEG格式后还报这个错误吗?
    A:我只改了改保存图片的文件名称B:我建议您将img.Save(FilePath,ImageFormat.Bmp);更改为img.Save(FilePath, ImageFormat.Jpeg);
    另外还需要将this.Image1.ImageUrl="Image\\doc.bmp";更改为转换好的Jpeg文件,因为Http协议不支持bmp,据我所知这就是引起才错误的原因。
      

  9.   

    to musttieying(铁鹰):
    我按你的帖子该修的都修改了,都不管用
      

  10.   

    我也曾经遇到过这问题,也没解决,最后用try跳过错误
      

  11.   

    UpPhoto.PostedFile.SaveAs(Server.MapPath("/tpxx/albums/"+UpPhoto.PostedFile.FileName.Substring(UpPhoto.PostedFile.FileName.LastIndexOf('\\')+1)));//将图片上传到albums目录下
    这一句,建议先使用 
    UpPhoto.PostedFile.SaveAs(@"c:\Inetpub\wwwroot\1.gif");这个保存测试一下,因为,如果你保存的路径不正确,也会产生这个错误。
      

  12.   

    musttieying(铁鹰) (厉害,类似问题我刚好也遇到了。解决了。