Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/337.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
C# 将位图保存到输出流时出错-“;GDI+;中发生一般性错误&引用;_C#_Asp.net - Fatal编程技术网

C# 将位图保存到输出流时出错-“;GDI+;中发生一般性错误&引用;

C# 将位图保存到输出流时出错-“;GDI+;中发生一般性错误&引用;,c#,asp.net,C#,Asp.net,我只是想给响应.OutputStream写一个位图。以下是我所拥有的: System.Drawing.Bitmap outputImage = System.Drawing.Image.FromHbitmap(psd.GetHBitmap()); Response.Clear(); Response.ContentType = "image/bmp"; Response.Flush(); // error occurs here outputImage.Sav

我只是想给
响应.OutputStream
写一个位图。以下是我所拥有的:

System.Drawing.Bitmap outputImage = 
    System.Drawing.Image.FromHbitmap(psd.GetHBitmap());            
Response.Clear();
Response.ContentType = "image/bmp";
Response.Flush();

// error occurs here
outputImage.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Bmp);

outputImage.Dispose();
Response.End();
有人知道可能是什么问题吗?

从MSDN上的文档中:

Windows或ASP.NET服务中不支持System.Drawing命名空间中的类。试图在这些应用程序类型中使用这些类可能会产生意外问题,例如服务性能降低和运行时异常。有关受支持的替代方案,请参阅Windows映像组件

您似乎找到了它不受支持的原因之一

下面是一个例子,解释问题的来龙去脉


除了MSDN上的警告中提到的选项外,还有中提到的其他选项。

我在ASP.NET环境中遇到的许多GDI错误都涉及文件夹/文件权限问题,这些问题可能不适用于此处。辅助进程是否具有对原始文件的读取权限?您是否正在将临时文件写入WP无权访问的文件夹