GDI +中出现一般错误。为什么会引发此异常? [英] A generic error occured in GDI+. Why is this exception being raised?

查看:97
本文介绍了GDI +中出现一般错误。为什么会引发此异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将HTML文本转换为.bmp图像。我正在使用以下代码执行操作。



I''m trying to convert HTML Text to a .bmp image. I''m using the following code for performing the operation.

Bitmap m_Bitmap = new Bitmap(400, 600);
PointF point = new PointF(0, 0);
SizeF maxSize = new System.Drawing.SizeF(500, 500);

HtmlRenderer.HtmlRender.Render(Graphics.FromImage(m_Bitmap), "<html><head></head><body><p>This is a sh*tty html code</p><p>This is another html line</p></body>", point, maxSize);

m_Bitmap.Save(@"C:\Test.bmp");





HtmlRenderer是这里使用的外部命名空间。但是,我在m_Bitmap.Save(@C:\ Test.bmp)中得到一个例外;该行说: GDI +中发生了一般性错误。



我无法理解为什么会出现这种异常的原因代码在我同事的系统中运行得很好。



请帮忙。非常感谢。



"HtmlRenderer" is an external namespace that is being used here. However, I''m getting an exception at the "m_Bitmap.Save(@"C:\Test.bmp");" line that says : A generic error occured in GDI+.

I''m unable to understand why this exception is being raised when the same code is running perfectly in my colleague''s system.

Please help. Thanks a lot.

推荐答案

解决了。当我试图将图像保存在根目录(C:\)中时,程序必须具有管理员权限。我早先错过了。当我使用管理员权限运行程序时,它按预期工作。
Solved. As I was trying to save the image in the root directory (C:\), the program had to have admin privileges. I missed out on that earlier. When I ran the program with admin rights, it worked as expected.


这篇关于GDI +中出现一般错误。为什么会引发此异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆