BufferedGraphicsContext 错误
在使用应用程序几个小时后,我每天都会同时收到以下错误和调用堆栈。 谁能解释一下正在发生的事情吗?
System.InvalidOperationException: BufferedGraphicsContext cannot be disposed of because a buffer operation is currently in progress.
at System.Drawing.BufferedGraphicsContext.Dispose(Boolean disposing)
at System.Drawing.BufferedGraphicsContext.Dispose()
at System.Drawing.BufferedGraphicsContext.AllocBufferInTempManager(Graphics targetGraphics, IntPtr targetDC, Rectangle targetRectangle)
at System.Drawing.BufferedGraphicsContext.Allocate(IntPtr targetDC, Rectangle targetRectangle)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.MenuStrip.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I am getting the below error and call stack at the same time everyday after several hours of application use. Can anyone shed some light on what is happening?
System.InvalidOperationException: BufferedGraphicsContext cannot be disposed of because a buffer operation is currently in progress.
at System.Drawing.BufferedGraphicsContext.Dispose(Boolean disposing)
at System.Drawing.BufferedGraphicsContext.Dispose()
at System.Drawing.BufferedGraphicsContext.AllocBufferInTempManager(Graphics targetGraphics, IntPtr targetDC, Rectangle targetRectangle)
at System.Drawing.BufferedGraphicsContext.Allocate(IntPtr targetDC, Rectangle targetRectangle)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.MenuStrip.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
MSDN 论坛对此错误进行了很长的讨论此处。 在大多数情况下,错误显然与以下任一相关:
我记得大约一年前我自己看到了这个错误,它肯定与内存问题有关,导致我们的应用程序在长时间运行后填满了所有可用的虚拟机,所以#1 与我所观察到的一致。
There is a very long MSDN forums discussion of this error here. In most cases the error is apparently associated with either:
I recall seeing this error myself a year or so ago, and it was definitely associated with a memory problem that made our app fill up all available VM after a long run, so #1 agrees with what I have observed.
我知道这个问题很老了,但我遇到了同样的问题,并发现,当我使用多个实现手动双缓冲的控件时,它才出现。
对我来说,我此时发现了问题:
所以我的所有控件都使用当前上下文,我认为它始终是相同的。
在我将其替换为
一切后,一切都按预期进行。
我希望这有点帮助。
I know this question is old, but i had the same problem and found out, that it only showed up, when i used multiple controls which implemented manual double buffering.
For me, i found the problem at this point:
So all my controls used the Current context, which i assume is always the same.
After i replaced it by
everything works like wanted.
I hope this is a little bit helpfull.
黑暗中的一枪——你是用多线程绘画吗? 如果您正在做与绘画相关的工作,请在 GUI 线程上进行或仔细同步您的代码。
a shot in the dark - are you painting from multiple threads? If you are doing painting related work, do it on the GUI thread or synchronize your code carefully.