GDI 中发生一般错误

发布于 2024-09-05 04:29:20 字数 638 浏览 1 评论 0原文

GDI+ 中发生一般错误

[ExternalException (0x80004005): GDI+ 中发生一般错误。] System.Drawing.Image.Save(Stream流,ImageCodecInfo编码器,EncoderParameters编码器参数)+615257

我有一个网页,其中将pdf转换为png,并使用response.outputstream 它被显示。当我在本地计算机上运行它时工作正常。但是当我在服务器上运行相同的代码时会抛出此异常。

我的问题是,我可以在哪里查找错误。因为没有内部异常或提供任何其他信息。唯一的线索是它发生在 Image.Save 上,但是相同的代码在我的本地计算机上运行得很好,那么它在生产中不起作用吗???

http://blog.maartenballiauw.be/ post/2008/05/13/ASPNET-MVC-custom-ActionResult.aspx

这是我正在关注的示例

A generic error occurred in GDI+

[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams) +615257

I have a webpage in which a pdf is converted to png, and using the response.outputstream
it is displayed. when i run this on my local machine is works fine. but when i run the same code on server is throws this exception.

my question is , where i could look in for error. as there is no inner exception or any other information provided. only clue is that it's happening on Image.Save , but the same code works perfectly fine on my local machine , then y is it not working on production???

http://blog.maartenballiauw.be/post/2008/05/13/ASPNET-MVC-custom-ActionResult.aspx

this is the example i am following

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

掐死时间 2024-09-12 04:29:20

Take a look at the big "Caution" note in the System.Drawing documentation. All kinds of weird stuff can happen when you use something intended for desktop processing in a service process.

Check the usuals like permissions, path existence, framework version, etc.

紫竹語嫣☆ 2024-09-12 04:29:20

这对我有用。写入 MemoryStream,然后将 MemoryStream 写入输出。推理和代码在这里: https://weblog.west-wind.com/posts/2006/Oct/19/Common-Problems-with-rendering-Bitmaps-into-ASPNET-OutputStream

This worked for me. Writing to MemoryStream and then Write the MemoryStream to the Output. Reasoning and code is here: https://weblog.west-wind.com/posts/2006/Oct/19/Common-Problems-with-rendering-Bitmaps-into-ASPNET-OutputStream

寄居人 2024-09-12 04:29:20

我将 Image 重载方法更改为

Image.Save(context.HttpContext.Response.OutputStream, ImageCodecInfo编码器, EncoderParametersencoderParams)

使用 Image.Save(context.HttpContext.Response.OutputStream,ImageFormat)

之前我在更改重载方法后 保存,它修复了错误。

I changed my Image over load method to

Image.Save(context.HttpContext.Response.OutputStream, ImageCodecInfo encoder, EncoderParameters encoderParams)

earlier i was using Image.Save(context.HttpContext.Response.OutputStream,ImageFormat)

after changing the overload method for save , it fixed the error.

终止放荡 2024-09-12 04:29:20

我通过以管理员身份运行在 Windows 7 计算机上安装了我的应用程序。

这对我有用。

I installed my application on a Windows 7 machine by running as administrator.

This worked for me.

送舟行 2024-09-12 04:29:20

不久前我也遇到过类似的事情……通常与安全有关。不要从 dev 复制 png,(如果有的话)服务器可能无法覆盖并确保 asp 进程对您尝试保存的目录具有写入权限。

I had something similar a while back ... usually to do with security. Don't copy the png over from dev, (if you have one) the server probably won't be able to overwrite and make sure the asp proccess has write access to the dir you're attempting to save to.

我ぃ本無心為│何有愛 2024-09-12 04:29:20

可能是 asp.net 工作进程没有权限创建您尝试在服务器上保存图像的文件。

It is probably that the asp.net worker process does not have permision to create a file where you are trying to save the image on the server.

独守阴晴ぅ圆缺 2024-09-12 04:29:20

当文件已经存在时,这发生在我身上。保存之前删除文件解决了问题。这是多么无益的错误消息啊。

This happened for me when the file already existed. Deleting the file before save resolved the problem. What an incredibly unhelpful error message.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文