出现了outofmemoryexception 异常,是个什么异常,怎么解决? 参考http://www.cnblogs.com/kwklover/archive/2005/05/05/149787.html 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我发现是我画图时使用了 bmp=new Bitmap(this.pictureBox1.Width,this.pictureBox1.Height); this.pictureBox1.Image=(Image)bmp;g=Graphics.FromImage(this.pictureBox1.Image);而产生的,我去掉后就不会产生这个异常了,但我也画不了图了,怎么解决啊??? bmp=new Bitmap(this.pictureBox1.Width,this.pictureBox1.Height); this.pictureBox1.Image=(Image)bmp; g=Graphics.FromImage(this.pictureBox1.Image); try changing to:if( this.pictureBox1.Image == null ){ this.pictureBox1.Image = new Bitmap(this.pictureBox1.Width,this.pictureBox1.Height); }g=Graphics.FromImage(this.pictureBox1.Image); Dispose()方法看看有没有,及时释放下 不是合法的图片文件就会报内存溢出,这是微软的bug using{ bmp=new Bitmap(this.pictureBox1.Width,this.pictureBox1.Height); this.pictureBox1.Image=(Image)bmp; g=Graphics.FromImage(this.pictureBox1.Image); }或if(bmp!=null&&!bmp.Disposed){bmp.Dispose();} bmp=new Bitmap(this.pictureBox1.Width,this.pictureBox1.Height); this.pictureBox1.Image=(Image)bmp; g=Graphics.FromImage(this.pictureBox1.Image); using{ bmp=new Bitmap(this.pictureBox1.Width,this.pictureBox1.Height); this.pictureBox1.Image=(Image)bmp; g=Graphics.FromImage(this.pictureBox1.Image); }或if(bmp!=null&&!bmp.Disposed){bmp.Dispose();} bmp=new Bitmap(this.pictureBox1.Width,this.pictureBox1.Height); this.pictureBox1.Image=(Image)bmp; g=Graphics.FromImage(this.pictureBox1.Image); using{ bmp=new Bitmap(this.pictureBox1.Width,this.pictureBox1.Height); this.pictureBox1.Image=(Image)bmp; g=Graphics.FromImage(this.pictureBox1.Image); }或if(bmp!=null&&!bmp.Disposed){bmp.Dispose();} bmp=new Bitmap(this.pictureBox1.Width,this.pictureBox1.Height); this.pictureBox1.Image=(Image)bmp; g=Graphics.FromImage(this.pictureBox1.Image); WPF 这段代码如何使得 ProgressBar 充满整个Column格子? 在ASP.NET(c#)中调用wsChart图表组件生成柱状图 无法新建office项目 求一个sql语句,类似交叉表 C#如何调用C++ Builder 6 的CHART控件?? ConfigurationManager.AppSettings总是取不到值啊~!~ 大家有没有过经济上的挫折呢?一起讨论 C#开发WAP vs2012 发布成功了但是目标目录中没有文件生成, SQL字符转化 C#和mfcsocket的问题 哪位大哥会FTP上传的代码
this.pictureBox1.Image=(Image)bmp;
g=Graphics.FromImage(this.pictureBox1.Image);
而产生的,我去掉后就不会产生这个异常了,但我也画不了图了,怎么解决啊???
bmp=new Bitmap(this.pictureBox1.Width,this.pictureBox1.Height);
this.pictureBox1.Image=(Image)bmp;
g=Graphics.FromImage(this.pictureBox1.Image);
try changing to:
if( this.pictureBox1.Image == null )
{
this.pictureBox1.Image = new Bitmap(this.pictureBox1.Width,this.pictureBox1.Height);
}
g=Graphics.FromImage(this.pictureBox1.Image);
{
bmp=new Bitmap(this.pictureBox1.Width,this.pictureBox1.Height);
this.pictureBox1.Image=(Image)bmp;
g=Graphics.FromImage(this.pictureBox1.Image);
}或
if(bmp!=null&&!bmp.Disposed)
{
bmp.Dispose();
}
bmp=new Bitmap(this.pictureBox1.Width,this.pictureBox1.Height);
this.pictureBox1.Image=(Image)bmp;
g=Graphics.FromImage(this.pictureBox1.Image);
{
bmp=new Bitmap(this.pictureBox1.Width,this.pictureBox1.Height);
this.pictureBox1.Image=(Image)bmp;
g=Graphics.FromImage(this.pictureBox1.Image);
}或
if(bmp!=null&&!bmp.Disposed)
{
bmp.Dispose();
}
bmp=new Bitmap(this.pictureBox1.Width,this.pictureBox1.Height);
this.pictureBox1.Image=(Image)bmp;
g=Graphics.FromImage(this.pictureBox1.Image);
{
bmp=new Bitmap(this.pictureBox1.Width,this.pictureBox1.Height);
this.pictureBox1.Image=(Image)bmp;
g=Graphics.FromImage(this.pictureBox1.Image);
}或
if(bmp!=null&&!bmp.Disposed)
{
bmp.Dispose();
}
bmp=new Bitmap(this.pictureBox1.Width,this.pictureBox1.Height);
this.pictureBox1.Image=(Image)bmp;
g=Graphics.FromImage(this.pictureBox1.Image);