【发布时间】:2015-04-28 14:02:57
【问题描述】:
运行此代码时遇到JIT 编译错误
void draw(PaintEventArgs e)
{
Graphics gr =this.CreateGraphics();
Pen pen = new Pen(Color.Black, 5);
int x = 50;
int y = 50;
int width = 100;
int height = 100;
gr.DrawEllipse(pen, x, y, width, height);
gr.Dispose();
SolidBrush brush = new SolidBrush(Color.White);
gr.FillEllipse(brush, x,y,width,height);
}
错误说:系统参数异常:无效参数 FillEllipse(Brush, int32 x,int32 y,int32 width,int 32 height);
【问题讨论】:
-
您确实意识到您实际上是在处理
Graphics对象然后尝试再次使用它,对吗? -
啊抱歉,我在发帖后提到了,但现在我有另一个问题,如何在不同的显示器中使表单大小保持静态?由不同的维度?对不起,谢谢你
-
使用
CreateGraphics几乎总是一个错误。你的draw方法有一个PaintEventArgs传递给它,我假设你是从某种Paint事件中得到的。您应该使用来自它的 Graphics 实例:Graphics gr = e.Graphics。也不要丢弃它。
标签: c# exception graphics drawing ellipse